D
David Tandberg-Johansen
Hello!
I am an newbie, and I am a litle stuck here. Could anyone please tell me
what I am doing wrong?
Here is my code:
#include <stdio>
#include <stdlib>
struct node {
char name[30];
struct node *next;
};
struct node *Head, *new_ptr;
void main(){
int length,counter;
char value[30];
printf("How many nodes: ");
scanf("%d",&length);
Head = NULL;
for(counter=0; counter<length; counter++){
new_ptr = malloc(sizeof(struct node));
if(new_ptr==NULL){
printf("not enough memory\n");
break;
}
printf("Enter the name (max 30 chr) for node %d: ",counter);
scanf("%s",&value);
new_ptr->name = value;
new_ptr->next = Head;
Head = new_ptr;
}
}
I am using the Borland c compiler an here is the error message:
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
C:\c-files\14-1-04\struct4.c:
Error E2277 C:\c-files\14-1-04\struct4.c 24: Lvalue required in function
main
*** 1 errors in Compile ***
I checked up this lvalue in the comp.lang.c FAQ, but i didn't understand
what concrete i am doing wrong?!
Thanks in advanced
David
I am an newbie, and I am a litle stuck here. Could anyone please tell me
what I am doing wrong?
Here is my code:
#include <stdio>
#include <stdlib>
struct node {
char name[30];
struct node *next;
};
struct node *Head, *new_ptr;
void main(){
int length,counter;
char value[30];
printf("How many nodes: ");
scanf("%d",&length);
Head = NULL;
for(counter=0; counter<length; counter++){
new_ptr = malloc(sizeof(struct node));
if(new_ptr==NULL){
printf("not enough memory\n");
break;
}
printf("Enter the name (max 30 chr) for node %d: ",counter);
scanf("%s",&value);
new_ptr->name = value;
new_ptr->next = Head;
Head = new_ptr;
}
}
I am using the Borland c compiler an here is the error message:
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
C:\c-files\14-1-04\struct4.c:
Error E2277 C:\c-files\14-1-04\struct4.c 24: Lvalue required in function
main
*** 1 errors in Compile ***
I checked up this lvalue in the comp.lang.c FAQ, but i didn't understand
what concrete i am doing wrong?!
Thanks in advanced
David