c - Issue with printing 2D array of structs with "\n" -
I am trying to print a 2D array strokes using printf in box formation. Each structure has an int and char value. When I try to print them, it only prints the int value, but prints four values instead of printing it. When I tell the print statement, to go to a new line after the other for the loop (The printf ("\ n") terminates it, so it just prints fine (except that it is not in the formation of the box.) Is it something strange that the quark or what am I seeing? / P>
for (int i = 0; i output Looks like this:
99� 99� 99� 99� 99� 99� 99� 99� 99� 99�991 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 ¿99 99 ¿½ 99 ¿½ 99 ¿99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 Here's my complete code:
#include gt; # Include class.h 'void corUsage (argc) {if (argc == 1) {printf ("Usage: .tokenize tm_file \ n"); Exit (1);}} int curState = 0; Four traction = 0; Zero matok (four * str) {char * ptr = str; Ptr = strtok (str, "/"); Cursstate = etoi (ptr); Ptr = strtok (NULL, ""); Traction = ptr; // printf ("% d /% s", cursstate, traction); } Structure matrix {{int state; Four functions; }; Int main (int argc, char * argv []) {corUsage (argc); // file is given (argc [1]) FILE * fp; Fp = fopen (argv [1], "r"); // Check for errors if (fp == NULL) {// error is compromised (argv [1]); Exit (1); } Four buffers [256]; // A buffer that fills up the stuff * ptr = buffer; // buffer character * ptr2; // For an indicator MISC Int states; // Start the number of states int; // accept initial state int; // end state // read the first three rows of the tm.x file and // it is in the above variable / store Ptr = fgets (buffer, 256, FP); Ptr2 = strtok (PTR, ""); Ptr2 = strtok (NULL, ""); States = Atoi (PTR2); Ptr = fgets (buffer, 256, fp); Ptr2 = strtok (PTR, ""); Ptr2 = strtok (NULL, ""); Start = etoi (ptr2); Ptr = fgets (buffer, 256, fp); Ptr2 = strtok (PTR, ""); Ptr2 = strtok (NULL, ""); Accept = Atoy (PTR2); Structure Matrix M.Ere [states] [12]; // 2D array that holds the strokes ((ptr = fgts (buffer, 256, fp)) = null) {four * br = strotok (ptr, ""); Int idx = atio (cr); Four * buffer 2 [256]; // a buffer int for = 0 misc data = 0; // counter globular which tells how many things are in line (cur = strtok (NULL, ""); cur! = NULL; cur = strtok (NULL, "")) {buffer 2 [to]] = cr; // Probably not in the form of indicator? Co ++; } For (int q = 0; q Reading in that file:
state starts 10 0 0 / 0d 1 / 0d 2 / 1s 3 / 3s 4/2 S 5/2 S 6/5 S 7/4 S 8/4 S 10/9 D1 0/9 D 1/9 D2/1 S 3/1 S 4/1 S 5/1 S 10 / 9d2 / 0d / d 1/9 d3/2 s 4/2 s 5/2 s 10/9 d3 0/9 d 1/9 d3/3 s 4/3 s 5/9 d10 / 9D4 0/9 D 1/9 d10/9 D5 0/9 D 1/9 D 7/6 S 10 / 9D6 0/6 S 1/6 S 2/6 S 3/6 S 4/6 S 5/6 S 6/6 S 7/7 S 8/6 S 9/6 S 10/9 D7 0/6 S 1/6 S 2/6 S 3/6 S 4/6 S5 / 6S 6/8S7/7S8/6S9/6S10/9D8 0/9D/9D/10/9D
That is, so I got it.
In this loop:
for (int q = 0; q I declare var.action = "d"; It should be var.action = 'd'; Only in single quotes. Thank you for seeing someone at that time.
Comments
Post a Comment