Hi,
I'm trying to do something that is easy.. .but it doesn't seem to be working right.
From the command prompt.. the user should enter the name of the program to run followed by a .txt file. The .txt file has in it two numbers.. let's say 5 77.
I want those numbers to be saved in my integer variables numberA and numberB respectively.
here is what I have so far.. but it doesn't work...
Code:int main (int argument1,char*argumentx[]) { int numberA,numberB,c; FILE *myfile; myfile = fopen(argumentx[1],"r"); if (argument1 != 2) { printf("Error: you have input too many arguments. Try again."); } if (myfile == NULL) { printf("Error: Invalid filename supplied (%s)\n",argumentx[1]); } while ((c = fgetc(myfile)) != EOF) { numberA = fgetc(myfile); numberB = fgetc(myfile); printf("the numberA has a value of %d\n",numberA); printf("the numberB has a value of %d\n",numberB); }
the printf does not even print the correct numbers.
Any suggestions?
Thanks in advance!