Please help me to correct this C++ console application

I'm very new to C++ programing. I'm getting 79 errors. Please help me to correct this...

// leave System.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>
#include <iomanip>
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <fstream>

using namespace std;





int main(){
login();
return 0;
}

void mainmenu(){
system("cls");
int option;
cout<<""<< endl;
cout<<""<< endl;
cout<<""<< endl;
cout<<" ***********************************************************************"<< endl;
cout<<" | WELCOME TO THE ICBT LEAVE SYSTEM |"<< endl;
cout<<" **********************************************************************"<< endl;
cout<<" | |"<< endl;
cout<<" | <enter> 1: Leave Menu |"<< endl;
cout<<" | <enter> 2: EXIT |"<< endl;
cout<<" | |"<< endl;
cout<<" **********************************************************************"<< endl;
cout<<" Option : ";
cin>>option;
switch(option){
case 1 :
Leave Menu();
break;

case 2:
exit();
break;


default:
mainmenu();
break;

}

getch();
}

void login(){
system("cls");
int count = 0;
string Uname;
string Pword;
for(;count<3;){
system("cls");
cout<<""<< endl;
cout<<""<< endl;
cout<<""<< endl;

cout<<" ENTER YOUR USER NAME: " <<endl;
cin>>Uname;
cout<<""<<endl;
cout<<" ENTER YOUR PASSWORD: "<<endl;
cin>>Pword;
cout<<""<<endl;

if((Uname == ("harshi")) && (Pword == ("123")))
{
adminmenu();
break;

}else{
cout<<" Incorrect Username or Password";
cout<<""<<endl;
cout<<""<<endl;
getch();
count++;
if(count == (3)){
mainmenu();
}
}
}

}


}
cout<<endl;
int option;
cout<<""<< endl;
cout<<""<< endl;
cout<<""<< endl;
cout<<" -----------------------------------------------------------------------"<< endl;
cout<<" | ICBT Management Leave System |"<< endl;
cout<<" -----------------------------------------------------------------------"<< endl;
cout<<" | |"<< endl;
cout<<" | Press 1 for Annual Leave |"<< endl;
cout<<" | Press 2 for Casual leave |"<< endl;
cout<<" | Press 3 for Sick leave |"<< endl;
cout<<" | Press 4 exit |"<< endl;
cout<<" | |"<< endl;
cout<<" -----------------------------------------------------------------------"<< endl;
cout<<" Option : ";
cin>>option;
switch(option){
case 1 :
annualLeave();
break;

case 2:
casualLeave();
break;

case 3 :
sickLeave();;
break;

case 4 :
exit();
break;

default:
mainmenu();
break;

}

getch();


}else{
mainmenu();
}
void exit(){
system("cls");

cout<<""<< endl;
cout<<""<< endl;
cout<<""<< endl;
cout<<""<< endl;
cout<<""<< endl;
cout<<""<< endl;
cout<<""<< endl;
cout<<""<< endl;
cout<<""<< endl;
cout<<" ---------------------------------------------"<< endl;
cout<<" | Thank you |"<< endl;
cout<<" ---------------------------------------------"<< endl;
getch();
exit(0);
}
If you have errors, one thing you can do to help people help you is to post the errors. Probably only the first few are necessary. There tends to be a snowball effect where the first error(s) cause more down the line.

Just at a glance, the compiler doesn't encounter anything telling it what login is until well after you try to call it -- put a declaration/prototype for the function before main's definition.

Please use code tags to make it easier to read your code:
http://www.cplusplus.com/articles/jEywvCM9/
Any name that is used in a C++ program shall be declared before its usage.
For example the compiler does not know what mean login in the code below.

int main(){
login();
return 0;
}
Thanks Cire and vlad..
These are the errors that I'm getting.. Please help me..


--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
e:\c program for lila\ui\cpp1.cpp(20) : error C2065: 'login' : undeclared identifier
e:\c program for lila\ui\cpp1.cpp(42) : error C2065: 'Leave' : undeclared identifier
e:\c program for lila\ui\cpp1.cpp(42) : error C2146: syntax error : missing ';' before identifier 'Menu'
e:\c program for lila\ui\cpp1.cpp(42) : error C2065: 'Menu' : undeclared identifier
e:\c program for lila\ui\cpp1.cpp(46) : error C2660: 'exit' : function does not take 0 parameters
e:\c program for lila\ui\cpp1.cpp(60) : error C2373: 'login' : redefinition; different type modifiers
e:\c program for lila\ui\cpp1.cpp(80) : error C2065: 'adminmenu' : undeclared identifier
e:\c program for lila\ui\cpp1.cpp(99) : error C2143: syntax error : missing ';' before '}'
e:\c program for lila\ui\cpp1.cpp(99) : error C2143: syntax error : missing ';' before '}'
e:\c program for lila\ui\cpp1.cpp(99) : error C2143: syntax error : missing ';' before '}'
e:\c program for lila\ui\cpp1.cpp(103) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(103) : error C2501: 'cout' : missing storage-class or type specifiers
e:\c program for lila\ui\cpp1.cpp(103) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(104) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(104) : error C2501: 'cout' : missing storage-class or type specifiers
e:\c program for lila\ui\cpp1.cpp(104) : error C2086: 'cout' : redefinition
e:\c program for lila\ui\cpp1.cpp(104) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(105) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(105) : error C2501: 'cout' : missing storage-class or type specifiers
e:\c program for lila\ui\cpp1.cpp(105) : error C2086: 'cout' : redefinition
e:\c program for lila\ui\cpp1.cpp(105) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(106) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(106) : error C2501: 'cout' : missing storage-class or type specifiers
e:\c program for lila\ui\cpp1.cpp(106) : error C2086: 'cout' : redefinition
e:\c program for lila\ui\cpp1.cpp(106) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(107) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(107) : error C2501: 'cout' : missing storage-class or type specifiers
e:\c program for lila\ui\cpp1.cpp(107) : error C2086: 'cout' : redefinition
e:\c program for lila\ui\cpp1.cpp(107) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(108) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(108) : error C2501: 'cout' : missing storage-class or type specifiers
e:\c program for lila\ui\cpp1.cpp(108) : error C2086: 'cout' : redefinition
e:\c program for lila\ui\cpp1.cpp(108) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(109) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(109) : error C2501: 'cout' : missing storage-class or type specifiers
e:\c program for lila\ui\cpp1.cpp(109) : error C2086: 'cout' : redefinition
e:\c program for lila\ui\cpp1.cpp(109) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(110) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(110) : error C2501: 'cout' : missing storage-class or type specifiers
e:\c program for lila\ui\cpp1.cpp(110) : error C2086: 'cout' : redefinition
e:\c program for lila\ui\cpp1.cpp(110) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(111) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(111) : error C2501: 'cout' : missing storage-class or type specifiers
e:\c program for lila\ui\cpp1.cpp(111) : error C2086: 'cout' : redefinition
e:\c program for lila\ui\cpp1.cpp(111) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(112) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(112) : error C2501: 'cout' : missing storage-class or type specifiers
e:\c program for lila\ui\cpp1.cpp(112) : error C2086: 'cout' : redefinition
e:\c program for lila\ui\cpp1.cpp(112) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(113) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(113) : error C2501: 'cout' : missing storage-class or type specifiers
e:\c program for lila\ui\cpp1.cpp(113) : error C2086: 'cout' : redefinition
e:\c program for lila\ui\cpp1.cpp(113) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(114) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(114) : error C2501: 'cout' : missing storage-class or type specifiers
e:\c program for lila\ui\cpp1.cpp(114) : error C2086: 'cout' : redefinition
e:\c program for lila\ui\cpp1.cpp(114) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(115) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(115) : error C2501: 'cout' : missing storage-class or type specifiers
e:\c program for lila\ui\cpp1.cpp(115) : error C2086: 'cout' : redefinition
e:\c program for lila\ui\cpp1.cpp(115) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(116) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(116) : error C2501: 'cout' : missing storage-class or type specifiers
e:\c program for lila\ui\cpp1.cpp(116) : error C2086: 'cout' : redefinition
e:\c program for lila\ui\cpp1.cpp(116) : error C2143: syntax error : missing ';' before '<<'
e:\c program for lila\ui\cpp1.cpp(117) : error C2143: syntax error : missing ';' before '>>'
e:\c program for lila\ui\cpp1.cpp(117) : error C2501: 'cin' : missing storage-class or type specifiers
e:\c program for lila\ui\cpp1.cpp(117) : error C2143: syntax error : missing ';' before '>>'
e:\c program for lila\ui\cpp1.cpp(118) : error C2143: syntax error : missing ';' before 'switch'
e:\c program for lila\ui\cpp1.cpp(118) : error C2143: syntax error : missing ';' before '{'
e:\c program for lila\ui\cpp1.cpp(118) : error C2447: missing function header (old-style formal list?)
e:\c program for lila\ui\cpp1.cpp(145) : error C2143: syntax error : missing ';' before '}'
e:\c program for lila\ui\cpp1.cpp(145) : error C2143: syntax error : missing ';' before '}'
e:\c program for lila\ui\cpp1.cpp(145) : error C2143: syntax error : missing ';' before '}'
e:\c program for lila\ui\cpp1.cpp(147) : error C2143: syntax error : missing ';' before '}'
e:\c program for lila\ui\cpp1.cpp(147) : error C2143: syntax error : missing ';' before '}'
e:\c program for lila\ui\cpp1.cpp(147) : error C2143: syntax error : missing ';' before '}'
e:\c program for lila\ui\cpp1.cpp(148) : error C2143: syntax error : missing ';' before '{'
e:\c program for lila\ui\cpp1.cpp(148) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.
Creating browse info file...

Cpp1.exe - 79 error(s), 0 warning(s)
The error messages are clear enough. Why do you not read error messages?
It looks like most errors are just you forgetting ;


Why did you put << "" << in the first 3 lines?
1
2
3
cout<<""<< endl;
cout<<""<< endl;
cout<<""<< endl;


You don't need to have the "" when it's an empty line, you could just use the endl.
Thanks for the replies friends.. Still I cannot completely solve the issue.. Please help me further more...
@Smarty: Yeah, or he could just use this - combining those three lines.
cout << "\n\n" << endl;

@zeromahesh: There is clearly a lot you do not understand. Please examine my changes carefully; I am very new to C++, but my changes do indeed get your code to compile.

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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#include <cstdlib>
#include <iostream>
#include <string>
#include <conio.h>
#include <stdio.h>
#include <string.h>

using namespace std;

//Below this comment we prototype all functions that appear after the main function.
//If your compiler* encounters a function call without it first being recognized,
//then you will recieve an error.
//*???

void login();
void mainmenu();
void adminMenu();
void exit();
void leaveMenu();
void annualLeave();
void casualLeave();
void sickLeave();

int main()
{
    mainmenu();
    return 0;
}

void mainmenu(){
    system("cls");
    int option;
    cout<<"\n\n"<<endl;
    cout<<" ***********************************************************************"<< endl;
    cout<<" | WELCOME TO THE ICBT LEAVE SYSTEM |"<< endl;
    cout<<" **********************************************************************"<< endl;
    cout<<" | |"<< endl;
    cout<<" | <enter> 1: Leave Menu          |"<< endl;
    cout<<" | <enter> 2: Administrator Login |"<< endl;
    cout<<" | <enter> 3: EXIT                |"<< endl;
    cout<<" | |"<< endl;
    cout<<" **********************************************************************"<< endl;
    cout<<" Option : ";
    cin>>option;

        switch(option){
            case 1 :
                leaveMenu();
                break;

            case 2:
                login();
                break;

            case 3:
                exit();
                break;

            default:
                mainmenu();
                break;
        }

        getch();
    }

void login(){
    system("cls");
    int count = 0;
    string Uname;
    string Pword;

    while(count<3){

        system("cls");
        cout<<"\n\n"<<endl;

        cout<<" ENTER YOUR USER NAME: " <<endl;
        cin>>Uname;
        cout<<""<<endl;
        cout<<" ENTER YOUR PASSWORD: "<<endl;
        cin>>Pword;
        cout<<endl;

        if((Uname == ("harshi")) && (Pword == ("123")))
        {
            adminMenu();
            break;

        }else{
            cout<<" Incorrect Username or Password";
            cout<<"\n\n";
            getch();
            count++;
        }

        if(count == (3)){
            mainmenu();
            }
        }
    }


void adminMenu()
{
    cout << "Username and password accepted. Welcome!" << endl;
    cout << "Press the ENTER key to continue." << endl;
    getch();
    system("cls");
    cout << "Oops, this feature hasn't been designed yet!" << endl;
    cout << "Press the ENTER key to continue." << endl;
    getch();
    mainmenu();
}

void leaveMenu()
{
    system("cls");
    cout<<endl;
    int option;
    cout<<"\n\n\n";
    cout<<" -----------------------------------------------------------------------"<< endl;
    cout<<" | ICBT Management Leave System |"<< endl;
    cout<<" -----------------------------------------------------------------------"<< endl;
    cout<<" | |"<< endl;
    cout<<" | Press 1 for Annual Leave  |"<< endl;
    cout<<" | Press 2 for Casual Leave  |"<< endl;
    cout<<" | Press 3 for Sick Leave    |"<< endl;
    cout<<" | Press 4 for Main Menu     |"<< endl;
    cout<<" | Press 5 EXIT              |"<< endl;
    cout<<" | |"<< endl;
    cout<<" -----------------------------------------------------------------------"<< endl;
    cout<<" Option : ";
    cin>>option;

    switch(option){
        case 1 :
            annualLeave();
            break;

        case 2:
            casualLeave();
            break;

        case 3 :
            sickLeave();;
            break;

        case 4 :
            mainmenu();
            break;

        case 5 :
            exit();
            break;

            default:
                mainmenu();
                break;
        }

    getch();
}

void annualLeave()
{
    cout << "This feature is currently unavailable." << endl;
    cout << "Press the ENTER key to continue." << endl;
    getch();
    mainmenu();
}

void casualLeave()
{
    cout << "This feature is currently unavailable." << endl;
    cout << "Press the ENTER key to continue." << endl;
    getch();
    mainmenu();
}

void sickLeave()
{
    cout << "This feature is currently unavailable." << endl;
    cout << "Press the ENTER key to continue." << endl;
    getch();
    mainmenu();
}

void exit(){
    system("cls");

    cout<<"\n\n\n\n\n\n\n\n\n"<< endl;

    cout<<" ---------------------------------------------"<< endl;
    cout<<" | Thank you |"<< endl;
    cout<<" ---------------------------------------------"<< endl;
    getch();
    exit(0);
}


Please don't hesitate to ask if you have any questions.
Polaz thank u soooo much my friend.. It's working greatly.. I'm so happy... Thanks a lot.. I need to implement those functions also. I'll get the requirement and then let you know.. Then please help me. Thanks again... :)
Polaz I had a issue.. I compile and build your code on a Windows Xp machine using Microsoft Visual C++ 6.0 and ran it nicely... but when I copy that .exe file to Windows 7 machine and try to run using command line it says windows incompatible thing.. So how can I compile for Windows 7 using windows Xp..
@zeromahesh: I wish I could help, but I'm not very experienced in that aspect. You DO have a compiler for your Windows 7 machine, don't you?

Try using Code::Blocks; that's what I edited your code in - and my OS is Windows 7.

http://www.codeblocks.org/downloads/26#windows
Get codeblocks-12.11mingw-setup.exe on the first list.
Topic archived. No new replies allowed.