You forgot to include string.h.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
scanf("%s",&make);
scanf("%s",&model);
scanf("%s", &color);
scanf("%s",&plate);
scanf("%s ",&sfname);
These will have an effect that you did not intended.
The format %s is for strings or arrays of type char, and when you pass it to scanf you don't need the & operator. Futhermore you have declared those variables as a single type char. In these case it would be scanf("%c", &model) as an example. Change the argument in the scanf() and make all those single char variables into arrays of type char, is what the rest of you code seems to indicate.
scanf("%s ",&sfname);
Eliminate the extra space between thes and the closing "
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
Also we normally discourage the use of scanf() with"%s" because it will allow you to corrupt the program's memory by scribbling outside the boundry of the arrays. For example if make is declared as an array of 10 characters and you type 15 characters then scanf() will write the extra 5 characters somewhere in memory -- where is anyone's guess. A second disadvantage of scanf() with "%s" is that it will not capture more than one word -- it stops copying from the keyboard at the first white-space character. So you can not enter a make that has two or more spaces in the name.
The solution is to either get the characters one character at a time from the keyboard buffer (hard way) or call fgets() which will limit the input to the size of the program's input buffer.
char make[10];
printf("Enter make\n");
fgets(make, sizeof(make), stdin);
Now, one disadvantage of fgets() is that it will insert the '\n' character at the end of the input buffer if there is enough room. So you have to strip it back out
if( make[strlen(make)-1] == '\n')
make[strlen(make)-1] = 0;
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
> changed from single characters to arrays, and i'n still getting the same error.
But you didn't change the char parameters to char arrays at the same time.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
>I've included
So you have.
>changed from single characters to arrays
I can't really help you at this point. Your misunderstanding of data types is so complete and fundamental that it's impossible to write programs until you get a book on C and actually read it.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
What do you mean?
he means like this (note I added the asterisks to make, model and plate because all three require character arrays):
void insert(struct node** head, char *make,char *model, int year, char color, char *plate){
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343