cant remove that error

fatal error C1004: unexpected end of file found



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
#include<iostream.h>
#include<conio.h>
#include<string.h>
void stores();

void main ()
{
 int choice;
 cout<<"Welcome to the Pearl continental User control panel\n\n";
 cout<<"Please Choose the options given below\n";
 cout<<"1)-Enter Stores department\n";
 cout<<"2)-Enter Finance department\n";
 cout<<"3)-Enter Human Resource department\n";
 cin>>choice;
 if(choice==1)
 stores();
 
}
/////////////////////////////////////////////////////////////////////////////////////////////////
void stores()
{
	int pInput;
    int i;
    char pw[5],ch;
	cout<<"Welcome to the Stores department\nPlease enter your password to continue:";
    do
	{
    cout << "Enter Password: ";
    for ( i = 0; i < 5 && (pInput = getch()) != 13; ++i ) 
	{
    pw[i] = pInput;
    putch('*');
	}
  pw[i] = '\0'; // to stop taking input
  cout << endl;
  if ( strcmp(pw, "admin") == 0 ) 
  
    cout << "Correct" << '\n'; 
  else
  
    cout << "Incorrect" << '\n';
}
Last edited on
closed account (z05DSL3A)
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
#include<iostream.h>
#include<conio.h>
#include<string.h>
void stores();

void main ()
{
    int choice;
    cout<<"Welcome to the Pearl continental User control panel\n\n";
    cout<<"Please Choose the options given below\n";
    cout<<"1)-Enter Stores department\n";
    cout<<"2)-Enter Finance department\n";
    cout<<"3)-Enter Human Resource department\n";
    cin>>choice;
    if(choice==1)
    {
        stores();
    }
}

/////////////////////////////////////////////////////////////////////////////////////////////////


void stores()
{
    cout<<"Welcome to the Stores department\nPlease enter your password to continue:";
    int pInput;
    int i;
    char pw[5],ch;
    do
    {
        cout << "Enter Password: ";
        for ( i = 0; i < 5 && (pInput = getch()) != 13; ++i ) {
            pw[i] = pInput;
            putch('*');
        }while(pInput!=13);
        pw[i] = '\0'; // to stop taking input
        cout << endl;
        if ( strcmp(pw, "admin") == 0 ) 
        {
            cout << "Correct" << '\n';
        } else
        {
            cout << "Incorrect" << '\n';
        }


    }
    /*
    ** Simple formating of your code shows that you are missing a } here.
    */


Edit:
The comment might have been misleading. It was meant to indicate that as the last brace had not returned to the left hand side then it indicates that there is a missing brace. The missing one is the closing of the for loop and should be between lines 35 and 36
Last edited on
Please use code tags when posting source.

Count your braces.
braces are proper ive rechecked them in my .cpp still that error is there :s
closed account (z05DSL3A)
You have edited your code...you now do not have a while for your do!
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
#include<iostream.h>
#include<conio.h>
#include<string.h>
void stores();

void main ()
{
    int choice;
    cout<<"Welcome to the Pearl continental User control panel\n\n";
    cout<<"Please Choose the options given below\n";
    cout<<"1)-Enter Stores department\n";
    cout<<"2)-Enter Finance department\n";
    cout<<"3)-Enter Human Resource department\n";
    cin>>choice;
    if(choice==1)
        stores();
    
}
/////////////////////////////////////////////////////////////////////////////////////////////////
void stores()
{
    int pInput;
    int i;
    char pw[5],ch;
    cout<<"Welcome to the Stores department\nPlease enter your password to continue:";
    do
    {
        cout << "Enter Password: ";
        for ( i = 0; i < 5 && (pInput = getch()) != 13; ++i ) 
        {
            pw[i] = pInput;
            putch('*');
        }
    /*
     ** There should be a } while (...); around here somwhere
     */
    pw[i] = '\0'; // to stop taking input
    cout << endl;
    if ( strcmp(pw, "admin") == 0 ) 
        cout << "Correct" << '\n'; 
    else
        cout << "Incorrect" << '\n';
}

Topic archived. No new replies allowed.