h

asd
Last edited on
Auth()
Missing a ;
could show me the missing in the program !
i mean copy the prog, fix the error and show?
Thanks
could show me the missing in the program !
i mean copy the prog, fix the error and show?


Seriously? You can't find the line in your code that isAuth() and change it to Auth();?
i did that and it now shows me another error
In function `main':
[Linker error] undefined reference to `Userchange()'
[Linker error] undefined reference to `Members()'
[Linker error] undefined reference to `Passchange()'
[Linker error] undefined reference to `Auth()'
ld returned 1 exit status
Functions must be declared OUTSIDE the main function and BEFORE they are implemented
Here is the start of your code, properly indented:

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<fstream.h>
#include <process.h>
int main()
{
  int ch;
  char x;
  do
  {

    cout <<"Hello And Welcome To Dsz Cinemas\n";
    cout <<"Please Type In The Number Of Your Choice\n";
    cout <<"1. Booking Tickets\n";
     cout <<"2. Latest Updates\n";
    cout <<"3. Gold Membership\n";
    cout <<"4. Credits\n";
    cin >>ch;
    system("cls");

    if (ch==3)

    {
  
      using namespace std;

      void Auth(); // what is this doing here? 
      void Members(); // what is this doing here? 
      void Userchange(); // what is this doing here? 
      void Passchange(); // what is this doing here? 

      string inuser;
      string inpass;
      string user;
      int num = 0;
	  int ch;
	  char pass[BUFSIZ];
	  int i = 0;
	  string com;

	  main()  // Is this ANOTHER function called main? What are you doing?
      {


Your code goes on and on with functions being declared and defined inside other functions and repeated calls to main (which is BAD - do NOT call main yourself) and various other disasters.

Indent your code. Like I have above.
Indent. Your. Code.

You will then be able to see most of these disasters yourself.


i am new to c++ and have just done about 6 months of learning!
those codes is what i have copied from some blogs to make a cinema booking.
so if u would kindly make the necessary changes and print it here i will b thankful
#include <iostream.h>
#include <conio.h>
#include<fstream.h>
#include <process.h>
int main()
{
int ch;
char x;

do
{

cout <<"Hello And Welcome To Dsz Cinemas\n";
cout <<"Please Type In The Number Of Your Choice\n";
cout <<"1. Booking Tickets\n";
cout <<"2. Latest Updates\n";
cout <<"3. Gold Membership\n";
cout <<"4. Credits\n";
cin >>ch;
system("cls");

if (ch==3) //must put the login info under here

{

using namespace std;

void Auth();
void Members();
void Userchange();
void Passchange();


string inuser;
string inpass;
string user;
int num = 0;
int ch;
char pass[BUFSIZ];
int i = 0;
string com;

main();
{
system("cls");
cout<<"Welcome\n---------------------------\n\n";
while(num==0)
{
system("cls");
cout<<"Command: ";
cin>>com;
if(com=="login")
{
Auth();
}
else if(com=="change-pass")
{
Passchange();
}
else if(com=="change-user")
{
Userchange();
}
else if(com==com)
{
cout<<"Unknown command\n";
}
}
}
void Auth();
{
ifstream Passfile("password.txt", ios::in);
Passfile>>inpass;
ifstream Userfile("username.txt", ios::in);
Userfile>>inuser;
system("cls");
cout<<"USERNAME: ";
cin>>user;
cout<<"PASSWORD: ";
fflush(stdout);

while ((ch = getch()) != EOF
&& ch != '\n'
&& ch != '\r'
&& i < sizeof(pass) - 1)
{
if (ch == '\b' && i > 0)
{
printf("\b \b");
fflush(stdout);
i--;
pass[i] = '\0';
}
else if (isalnum(ch))
{
putchar('*');
pass[i++] = (char)ch;
}
}

pass[i] = '\0';

Userfile.close();
Passfile.close();
if(user==inuser&&pass==inpass)
{
Members();
}
else
{
cout<<"nope";
getch();
main();
}
}
void Userchange();
{
string tempass;
system("cls");
cout<<"enter current password: ";
cin>>tempass;
if(tempass==inpass)
{
cout<<"utility to change username stored in file\n";
cout<<"CHANGE USER TO: ";
cin>>user;
ofstream Userfile("username.txt", ios::out);
Userfile<<user;
Userfile.close();
cout<<"Username successfully changed";
getch();
main();
}
else
{
cout<<"Invalid Password";
getch();
main();
}
}
void Passchange();
{
string pass;
system("cls");
cout<<"enter current password: ";
fflush(stdout);

while ((ch = getch()) != EOF
&& ch != '\n'
&& ch != '\r'
&& i < sizeof(pass) - 1)
{
if (ch == '\b' && i > 0)
{
printf("\b \b");
fflush(stdout);
i--;
pass[i] = '\0';
}
else if (isalnum(ch))
{
putchar('*');
pass[i++] = (char)ch;
}
}

pass[i] = '\0';
if(pass==inpass)
{
cout<<"utility to change password stored in file\n";
cout<<"CHANGE PASS TO: ";
cin>>user;
ofstream Passfile("password.txt", ios::out);
Passfile<<user;
Passfile.close();
cout<<"password successfully changed";
getch();
main();
}
else
{
cout<<"Invalid Password: ";
getch();
main();
}
}
void Members();
{
system ("cls");
cout <<"wassup";

cout<<"nothing";
getch ();// put members code here
// like a while(){} loop or somethin like that
// comment please
}



cout <<"Our Gold membership is not available at the moment\nPlease try again later\n\n\n\n";

}


else if (ch>4)
cout <<"The number typed in is wrong Dum Dum =P\n\n\n\n";

cout<<"\n\nDo you wish to redo your selection and select another option or exit? (Y/N)\n";
cin>>x;
system("cls");
}
while (x=='Y'||x=='y');
cout <<"Thankyou for choosing Dsz Cinemas!!!\nSorry for any inconvenience\nHope to see you again ^.^ :D\nBye";
getch();
exit(0);

getch();
}

this is the change i made and i got linker errors for
wat do you mean by indented?
Here is some code that is not indented:
1
2
3
4
5
6
7
8
9
10
#include <process.h>
int main()
{
int ch;
char x;

do
{

cout <...


Here is the same code, indented:
1
2
3
4
5
6
7
8
9
10
#include <process.h>
int main()
{
  int ch;
  char x;

  do
  {

      cout <...

See how you can tell by looking what code is inside what set of braces? This makes it much easier to tell when you have, for example, got your do-while loop wrong, or forgotten to put the closing brace on, or started to define a function inside another function.
Last edited on
Topic archived. No new replies allowed.