I need some help, fairly new to C++ and I know a little about C. What i am trying to do is get a txt file that looks like this
4 //first number tells how many rows are coming next.
3 54
2 51
9 32
2 34
what i want to do is get the numbers into a array so that i can use them later on in a function. Here is what i wrote so far, and is there a better way in C++.
# include <stdio.h>
void READFile(char* filename)
{
int num;
FILE* inputfile;
if ((inputfile = fopen(filename, "r")) ==NULL)
{
printf("file not found, unable to open\n");
}
fscanf( inputfile, "%d", num);
int color[num];
int value[num];
for (int i = 0; i< num; i++);
{
fscanf(inputfile, "%d","%d", &color, &value);
}
}