I am trying to write a program which read a certain input in a particular format and then gives an ouput. I wrote a code to read the file. Input is something like this.
X 20 60 80 90
X 78 98 97 96
X 34 35 43 23
Y 76 87 34
Y 65 76 72
Z 13 70 39
So my reading function read the input and then it counts the number lines with X and Y. Now, when I wrote two different funcions to read X and Y lines. When I am finished reading the X lines, I go to read Y lines. The code skips the first Y line, because it has already read it without realising that it is a Y line, and then it read the next line while skipping the first Y line. Can I avoid that?
I use scanf to read the first character and then it is true I used scanf in a while loop to read the rest of the numbers and I store those numbers in an array.
As I know that it has already read the next character, can I test it if the character is Y? Because the input may not contain the Y line.