Function not declared in the scope??

This program in not completed. I am creating a large program in order to calculate a company's weekly payroll. For now I am filling in the separate functions piece by piece before the rest of the program is completed.

Right now I am trying to use separate functions to call other functions. I need to ask the user for the file name and then open the file.

I am getting error messages that the functions I am calling "NameTheFile" and "OpenTheFile" are not declared in the scope.

I'm searching everywhere and as far as I can see I'm declaring them correctly.

What is the problem??


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*Program to determine company's weekly payroll*/

#include <iostream>
#include <string>
#include <fstream>
using namespace std;

void NametheFile()
{

ifstream inputFile;
string filename;

//Asks user for file name.

cout << "What is the file name?\n.";
cin  >> filename;
OpenTheFile();

}

void OpenTheFile()
{

ifstream inputFile;
string filename;
char letter;
int number;

//Opens the file
inputFile.open(filename.c_str());

if (inputFile)
{
    while (inputFile >> letter)
    {
        cout << "File opened successfully.\n";
        cout << letter << endl;
    }

    //CLOSES THE FILE. (remove)
    inputFile.close();
}
else
    {
        //Error checking
        cout << "Error opening the file.\n";
    }
}

void GetTheData()
{
    //statement
    //statement
    //statement
}

void CalculateTheTotalPay()
{

    //statement
    //statement
    //statement
}

void PrintTheData()
{
    //statement
    //statement
    //statement
}

int main()
{
    //Main to call other functions
    cout << "Welcome.\n";
    NameTheFile();

    return 0;
}
The function on line 77 is not the same as the one on line 8 (t vs T). Function names in C++ are case sensitive.

Also, in OpenTheFile, filename should be an input parameter
I capitalized the "The" but now it is saying OpenTheFile is not declared.

What exactly do you mean by it needs to be an input parameter?

Edit: I fixed it, I had to put it before the function that calls it.
Last edited on
Topic archived. No new replies allowed.