c - parsing input and adding to struct array -
I have some code that is trying to get data from a file. The format is as follows: 9/2 D1/1 S file can be many of those people, but I have to take the first number and add it as an index. Then I have to save the next number and the character as different values. I have some code but it does not work very well.
structure matrix token [nbrState] [12]; Int * num = 0; Int index = 0; Whereas ((ptr = fgets (buf, 256, fp)) = = null) {ptrToken = strtok (buf, "/"); Int count = 0; (Calculation> = 3) {ptrToken = strtok (NULL, ""); index = etoi (PTT token); token [index] for index (int r r = 0; r & lt; 12; r ++) ] [R] .state = index;} calculation ++;}} This is my updated code. It works better.
structure Matrix token [nbrtte] [12]; four * torque; ind index = 0; int state = 0; while ((ptr = fgets (buf, 256, fp)) = = null {ptrToken = strtok (buf, "" ); Tok = ptrToken; // index = Strokecock (for "," / "); for (int r = 0; r
you can try it
while ((Fscanf (fscanf (fp, "% d /% d% c", and index, & separate intent, & separate customer) == 3) {// Token [index] [11] .state = sepatateInt;} will be continued as needed to use until the file does not match the EOF or input format.
Comments
Post a Comment