Ive been working on a project all day and I have come to a hault because fscanf isn't working the way I thought it was suppose to.
I am reading a file that contains something like this:
AND 0 3 2
Here is a peice of my code that is giving me problems:
while(fscanf(circuit, "s",cur_gate)!=EOF){
if(cur_gate[0]=='A'){
fscanf(circuit,"%d %d %d",&cur_output,&cur_input1,&cur_input2);
printf("current output: %d\n",cur_output);
printf("current input: %d current input2: %d\n",cur_input1,cur_input2);
So what I am doing is reading the file and checking if the string = AND (cur_gate). Then if it = 'A', i am reading 3 integers. I want to assign the first integer to cur_output and the second and third to cur_input1 and cur_input2, respectively.
The problem is that its output is:
current output: 0
current input: 0 current input2: 0
While the output should actually be:
current output: 0
current input: 3 current input2: 2
I honestly don't know what's wrong because I did almost the same thing earlier and it worked. Thanks for any help!