scanf never seems to work properly for me when using strings, code below and sample input file also.
sample input fileCode:int i = 0; FILE *file; file = fopen("playlist", "r"); if ( file == NULL ) { printf("\n\nPlaylist File Not Loaded!, Program Will Exit!\n\n\n"); exit(0); } while (!feof(file)) { fscanf(file,"%s %s %s %d",playlist[i].code,playlist[i].group,playlist[i].title,&playlist[i].no); i++; }
KILL Killers Somebody_told_me 3
GDAI Greenday American_idiot 2
BD56 Bob_Dylan all_along_the_watchtower 3
the output i get is for first one is
code:KILLKillers group:Killers title:Somebody_told_me no:3
as u can see all correct apart from the first one, ive tried putting %4s but still seems to add killers when it shouldnt do. can anyone help?
cheers



LinkBack URL
About LinkBacks


