#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdlib>
using namespace std;
int main() {
int numberArray[] = {};
int atoi(const char * str); // this fuction is used to convert the data into int
char line[10]; // this is a char array
const char filenames[] = {
'NumFile500.txt',
'NumFile5K.txt',
'NumFile25K.txt',
'NumFile100K.txt'
};
FILE * file; // declaring the FILE pointer as file pointer
for (int k = 0; k < 4; k++) {
int i = 0;
file = fopen(filenames[k], "r"); // error on this line while trying to open a text file for reading mode
while (fgets(line, sizeof line, file) != NULL) { // keep looping until NULL pointer...
numberArray[i]= atoi(line);
cout << atoi(line) << endl; // convert string to double float
}
}
}
Just want to read list of integers line by line from multiple text files but I am getting error invalid conversion from 'char' to 'const char*' [-fpermissive] I am new to CPP. pls help me with this