ok so I have three numbers in a file called input.dat and im able to call them but I want to know how to get those three numbers in that function and able to use them in other functions.
#include <stdio.h>
#include <iostream>
int main(int argc, char * argv[]){
int x = 0;
FILE * pFile;
pFile = fopen("numbers.txt", "r");
if (pFile){
fscanf(pFile, "%d+", &x);
fclose(pFile);
std::cout << x << std::endl;//yes I could have used printf, but again, yolo
//printf("%d", x);
}
}
output
>> 1
You could use what your os provided(like windows (win32) filesysteming thingy magigy)
ok I got it to work but now I want to have it to where the file can only read 3 lines of data I got it to work but I keep getting my error message to display when I already have my three numbers in the file any help would be appreciated.