-2
// Я реализовал простую связанную прокси-страницу в c здесь я реализую вставку сначала, в последнюю, конкретную позицию. эти ошибки произошли при исполнении: expected '=', ',', ' ;», 'ASM' или 'атрибута' перед '*' маркера
..Anyone угодит уточнить, что эти ошибкипростая программа связанного списка в c
#include<stdio.h>
#include<malloc.h>
#define ISEMPTY printf("\n empty list");
struct node{
int value;
struct node *next;
}
startnode * create_node(int);
void insert_node_first();
void insert_node_last();
void insert_node_position();
typedef struct node start_node;
start_node *newnode,*ptr,*prev,*temp;
start_node *first=NULL,*last=NULL;
int main()
{
int ch;
char ans='Y';
while(ans == 'Y' || ans == 'y')
{
printf("\n Single linked list \n");
printf("\n1.INSERT NODE AT FIRST");
printf("\n2.INSERT NODE AT LAST");
printf("\n3.INSERT NODE AT POSITION");
printf("\n ENTER YOUR CHOICE");
scanf("%d",&ch);
switch(ans)
{
case 1:printf("INSERT NODE AT FIRST");insert_node_first();break;
case 2:printf("INSERT NODE AT LAST");insert_node_last();break;
case 3:printf("INSERT NODE AT POSITION");insert_node_position;break;
default:printf("U DIDN'T SELECT ANYTHING SO EXCEED");
}
printf("DO YOU WANT TO CONTINUE");
scanf("%c",&ans);
}
return 0;
}
start_node* create_node(int val)
{
newnode=(start_node *)malloc(sizeof(start_node));
if(newnode==NULL)
{
printf("\n Memory not allocated");
return 0;
}
else{
newnode->value=val;
newnode->next=NULL;
return newnode;
}
}
void insert_node_first()
{
int val;
printf("Enter the value for the node");
scanf("%d",&val);
newnode=create_node(val);
if(first == last && first == NULL)
{
first=last=newnode;
first->next=NULL;
last->next=NULL;
}
else{
temp=first;
first=newnode;
first->next=temp;
}
printf("\n inserted");
}
void insert_node_last()
{
int val;
printf("Enter the value insert at last");
scanf("%d",&val);
newnode=create_node(val);
if(first == last && first == NULL)
{
first=last=newnode;
first->next=NULL;
last->next=NULL;
}
else{
last->next=newnode;
last=newnode;
last->next=NULL;
}
}
void insert_node_position()
{
int val,position,count,i;
printf("Enter the value to insert");
scanf("%d",&val);
newnode=create_node(val);
printf("Enter the position you want to ");
scanf("%d",&position);
ptr=first;
while(ptr !=NULL)
{
ptr=ptr->next;
count++;
}
if(position == 1)
{
if(first == last && first == NULL)
{
first=last=newnode;
first->next=NULL;
last->next=NULL;
}
else{
temp=first;
first=newnode;
first->next=temp;
}
}
else if(position > 1 && position<=count)
{
ptr=first;
for(i=1;i<position;i++)
{
prev=ptr;
ptr=ptr->next;
}
prev->next=newnode;
newnode->next=ptr;
printf("inserted at position");
}else{
printf("position is out of range");
}
}
Подсветка линии, где это происходит, будет идти долгий путь к получению помощи. Люди, не имеющие доступа к компилятору в настоящий момент, не будут анализировать всю вашу программу в их голове. – StoryTeller
'start_node' или' startnode'? Также актуальным является порядок заявлений. –
'struct node { int value; struct node * next; } ':'; 'добавить к последнему. Например, '}' -> '};'. – BLUEPIXY