-
scan a string
What is wrong? I am trying to read a user input. The input is a street address ex: 401 North Ave.
I can't get it to scan???
The street variable is part of a structure that I am using in a linked list.
printf("enter street address: ");
fgets(temp,sizeof(temp),stdin);
sscanf(temp,"%s", pcurrent->street);
-
What is temp defined as?
What is pcurrent->street as?
Why use sscanf() (which won't do what you want anyway)?
-
Your probably getting '401', right? sscanf scans the first item in the string, in this case, the street number. The best way is just to parse the string manually.
-
>>The best way is just to parse the string manually
... depending on what's what's wanted. A simple strcpy() might be all that is needed.
-
Are you kidding, man? Even if I needed the entire string I'd still parse it for good measure! :p