Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Why does that not compile? Please help me

0 votes
asked Apr 23, 2018 by Kito Termilien (170 points)
#include <iostream>

#include <fstream>

#include <string>

using namespace std;

static int fileReading(int, int, int);

const int arraySize = 12;

ifstream infile;

int main()

{

string filename;

const int arraySize = 12;

int arrayNumber[arraySize];

int input = 0;

cout << "Please Enter the name of the file to read numbers for number Analysis program\n";

cin >> filename;

infile.open(filename);

if (infile)

{

arrayNumber[arraySize] = fileReading(input, arrayNumber, arraySize);

}

else

cout << "The file did not open.";

return 0;

}

// Function that reads the contents of a file and stock them in an array

int fileReading(int input, int arrayNum[arraySize], int arraySize)

{

    int i;

for (i = 0; i < arraySize; i++)

{

infile >> input;

arrayNum[i] = input;

}

return i;

}

‚Äč

2 Answers

0 votes
answered Apr 25, 2018 by Bird Man (250 points)
Could you please type in the messages the compiler gives?
0 votes
answered Apr 27, 2018 by anonymous

Your fileReading function signature is wrong. Instead of

static int fileReading (int, int, int);

it should be 

static int fileReading(int, int*, int);

Compiler clearly tell you that:

main.cpp:32:74: error: invalid conversion from 'int*' to 'int' [-fpermissive]

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...