Program has cintax problems but I dont know what they are.

This following program has problems are at the end.
I deleted a big park of it, mostly the atbg sub program, so it would fit within the length maximum.

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
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <stdio.h>
using namespace std;
int atbg()
{
    
        int choice, Prounds;
        int guessr, answerr;
    string username, gplur, gender, gno, ap;
    Prounds = 5;



int hackeralert()
{
     string answer;
    cout<< "Are you a hacker? (Yes or No)\n";
    cin >> answer;
    if (answer== "yes")
    {
                 getchar();
              cout<< "COME OUT OF THE BUILDING WITH YOUR HANDS UP!\n";
              }
    else if (answer== "Yes")
    {
              getchar();
              cout<< "COME OUT OF THE BUILDING WITH YOUR HANDS UP!\n";
              }
              else if (answer == "No")
              {
                   getchar();
                  cout<<"You must just be an idiot.\n";
                  }
              else if (answer == "no")
              {
                   getchar();
                  cout<<"You must just be an idiot.\n";
                  }
              else
              {
                  "Failure.\n";
                  cin.ignore();
                  cin.ignore();
                  return 0;
                  }
                  }

int main()
//ask for password
{
    int thisnumber, thisnumber2, x;
    string password, ap;    
    cout<< "What is your password?\n";
    cin>> password;
    if (password == "P@ssw0rd")
//HERES WHERE THE PROBLEMS ARE 
//       |||
//       vvv

    {
    cout<<"Do you want a calculator, an text based game, or a number game?(calc, tbg, or ng.)\n";
    cin>>ap;
[b]    if (ap = "calc")
    {
    cout<<"\n";
    }
    if (ap = "tbg")
    {
 atbg();
}
if (ap = "ng")
{
       int iSecret, iGuess;

  /* initialize random seed: */
  srand ( time(NULL) );

  /* generate secret number: */
  iSecret = rand() % 100 + 1;

  do {
    printf ("Guess the number (1 to 100): ");
    scanf ("%d",&iGuess);
    if (iSecret<iGuess) puts ("The secret number is lower");
    else if (iSecret>iGuess) puts ("The secret number is higher");
  } while (iSecret!=iGuess);

  puts ("Congratulations!");
  return 0;
}
       }
}

else
{
    cout<< "Invalid.\n";
    hackeralert();
}
cout<< "\nPress enter to close..." << endl;
cin.ignore();
cin.ignore();
}
Do you know what kind of errors your getting? Also just a style tip: You should put srand() at the very beginning of your program so you don't accidently put it again.
you forgot to add a } at line 13, also in the MAIN function you "reproduced" the ap string of line 54, in line 64 why is there a [b] in there? its causing an extra error, ^_^ BTW: after the return 0; in MAIN you put 3 }}}... whys that?
Last edited on
Having a coherent style helps avoiding this sort of mistakes.
@mpruisu
Those errors are because I took out part of the program and didnt take out all corresponding brakets... sorry!
Your problem description has a syntax problem...
Topic archived. No new replies allowed.