error: expected constructor, destructor, or type conversion before '<<' token

Mar 15, 2013 at 9:51pm
hello, i am debugging my code, im getting the error: expected constructor, destructor, or type conversion before '<<' token, on line 16
any help would be appreciated, thankyou!
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
// DTLoader copyright 2013 Declan Thomas
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int question;
int install;
int run;
int cmd;
int nsupport;
int example;
int answer;
int answer2;
int notepadplusplus;
int main(int nNumberofArgs, char* pszargs[]);
cout << "Hello, Would you like to install or run a program?\n"
cin >> answer
{
    if (answer==install)
        system("cd \bat")
        system("install.bat")


    if (answer==run)

        cout << "What is the name of the application you would like to run?\n"
        cin >> answer2


    if (answer2==cmd)

        system("cd \bat")
        system("cmd.bat")


    if (answer2==notepadplusplus)

        system("cd \bat")
        system("notepadplusplus.bat");

system ("PAUSE")
Return 0;
 }
Mar 15, 2013 at 9:53pm
Something is wrong with line 15
Mar 16, 2013 at 3:43am
Your have two statements before main's {, And you are missing a bunch of ;
Mar 16, 2013 at 4:32am
There are bunch of errors in the code, first of all most of your statements are not terminated. Secondly, you're writing the control statements like you're writing comprehension in English.e.g.
1
2
3
4
5
if (answer==install)
//whats the value of install?
//right, install was declared as an integer, № value was assigned
//if install were a char, so that if answer='i' or string so that answer="install"
//then fine 

Your code needs several adjustments.
Mar 16, 2013 at 10:39pm
Your have two statements before main's {, And you are missing a bunch of ;

That fixed my problem main problem, thank you!

ive edited my code to make it compile-able, but it still dosn't work
when adding quote marks (eg answer="cmd") i get the error "error c++ forbids comparison between interger and pointer.",
sorry ive only been learning 1 week. any help?
thanks
here is the edited code:

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
// DTLoader copyright 2013 Declan Thomas
// this program (at current state) exacutes bat files which copys zips to a directory and unzips them, then gives the option to exacute exe files inside
// this is in alpha state, not representative of the final product
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int answer;
int answer2;
int install;
int run;
int cmd;
int notepadplusplus;
int main(int nNumberofArgs, char* pszargs[])
{
    system("title DTLoader Alpha 0.1");
    cout << "DTLoader (C) Declan Thomas 2013\n";
    cout << "To learn how to use DTLoader, read the included READ-ME-1ST File.\n";
    cout << "Enter a exacuteable command, or type cmd to open the command.com enviroment,";
    cout << "or cmda to open the CMD enviroment (only works if security is crap)\n";

    cin >> answer;

    if (answer == install); // im wanting it so when user types install, the following exacutes
       {
        system("CD C:\\Users\\Admin\\Desktop\\DTLoader\\bat");
        system("CALL install");
        system("PAUSE");
        return 0;
       }
    if (answer == cmd)
       {
           system ("echo off\n command \n command.com \n pause"); // This is an experement. 
                }


    if (answer == run);
       {
        cout << "What is the name of the application you would like to run?\n"; //The run command will allow the runing of programs
        cin >> answer2;



    if (answer2 == cmd);
    {
        system("CD C:\\Users\\Admin\\Desktop\\DTLoader\\bat"); // Command.com launcher
        system("CALL cmd.bat");
        return 0;
    }

    if (answer2 == notepadplusplus);
      {
        system("CD C:\\Users\\Admin\\Desktop\\DTLoader\\bat"); // notepadpp launcher
        system("CALL notepadplusplus.bat");
        system("PAUSE");
        return 0;
       }
}

system ("PAUSE"); // end
return 0;
}

Last edited on Mar 16, 2013 at 10:44pm
Mar 17, 2013 at 12:26am
Several of your if statements have semicolons after them- they should not.

if (answer == run);

Such as with this on line 37, there should be no semicolon.

Also, with that same if statement, you did not put a closing brace.
Last edited on Mar 17, 2013 at 12:27am
Mar 18, 2013 at 7:40pm
ah ha! blind mistake, thanks.
Ive been experementing with if and if i replace all the x's (answer == x)
with numbers it works, but not with words.
Topic archived. No new replies allowed.