I am starting to program in Visual Studio (C) and I'm simply trying to print the values in the file, one by one. I can easily do this in my Eclipse version. (Which is the exact same code). My txt file is in project folder as seen here: https://i.stack.imgur.com/vIeZR.png
The code is as follows:
#include <stdio.h>
int main(int argc, char **argv) {
int c;
FILE *file;
const char* file_name = "ECG.txt";
file = fopen(file_name, "r");
int i = 0;
fscanf(file, "%d", &i);
while (!feof(file))
{
printf("%d ", i);
fscanf(file, "%d", &i);
}
fclose(file);
return 0;
}
When I run this, I get the error stream != nullptr how can I fix this?