I am quite new to C and I have not used any examples of my problem, or I am completely wrong Understand what that solution was, I have a large file with the data that looks like:
LYS 24L HB 2 45.212 39.585 124.457 SC 0,045 -0.795 0.585 0.157
On each line I've already marked the data using strtok. What do I want to do in the second area, I want to store 24 as an integer to compare, and L has to be stored as a cell for comparatively comparisons.
I tried to use
sscanf (token [1], "% d% s", number, letter); But I'm getting a Segmentation fault error. Besides, I tried to print "LYS" (trying to understand my problem more) on experiment with sscanf further though My program will print L using only the following command:
sscanf (token [0], "% c", and stemp); Letter = stemp; Printf ("% c \ n", letter); However if the change is in% c ---> % S (hoping to get the whole string) then I get the segmentation fault error again ... is there anything that does not understand about sscanf command? Why can not I read the whole string ?? Thank you for your time and assistance!
Paul
I doubt this issue really is actually the Number and letters are of type int and char scanf () address of memory locations In order to store values, do not own the variable; I.e., integer number; Four letters [2]; Sscanf (token [1], "% d% s", and number, letter); I have made letter in an array of two letters, and am going through the address of the array; Which matches the % s scan conversion you used.
Comments
Post a Comment