Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


I'm damn new to C++
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Tue Oct 09, 2007 11:03 am    Post subject: I'm damn new to C++ Reply with quote

Hey guys, I hope you can help me out.

Im decided to start a bit c++. I searched for some tuts on google and found a simple tut (This but its german lol)
Well I checked in the "if and else" section and found this:
Code:
    #include <iostream>
    using namespace std;

    int main()
    {
        cout<<"Please enter a number\n";
        int a;
        cin>>a;
        cout<<"Please enter a once more number\n";
        int b;
        cin>>b;

        if(a==b)
        {
            cout<<"Both numbers are commensurate";
        }
        if(a<b)
        {
            cout<<a<<" is smaller then "<<b;
        }
        if(a>b)
        {
            cout<<a<<" is bigger then "<<b;
        }
        cout<<"\n";
    }


Very easy for you guys.. xD
But after I entered two numbers it just closes the application..WHY?
lol, Im just wondering cuz it should tell me something about these two numbers.
Please answer the question newbfriendly Smile

ty everyone!
Back to top
View user's profile Send private message
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Tue Oct 09, 2007 11:08 am    Post subject: Reply with quote

open your program from the cmd, or add a cin at the end
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Tue Oct 09, 2007 11:15 am    Post subject: Reply with quote

well lol yea I tried it already with cin.get(); but not everywhere.
Code:
    #include <iostream>
    using namespace std;

    int main()
    {
        cout<<"Please enter a number\n";
        int a;
        cin>>a;
        cout<<"Please enter a once more number\n";
        int b;
        cin>>b;

        if(a==b)
        {
            cout<<"Both numbers are commensurate";
         cin.get();
        }
        if(a<b)
        {
            cout<<a<<" is smaller then "<<b;
         cin.get();
        }
        if(a>b)
        {
            cout<<a<<" is bigger then "<<b;
         cin.get();
        }
        cout<<"\n";
      cin.get();
    }


Worked ! thx Smile
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Tue Oct 09, 2007 11:19 am    Post subject: Reply with quote

ur code shoudnt even compile.... you dont even return EXIT_SUCCESS (0)

revised script:

Code:
    #include <iostream>
    using namespace std;

    int main()
    {
        int a,b; 
        cout<<"Please enter a number\n";
        cin>>a;
        cout<<"Please enter a once more number\n";
        cin>>b;

        if(a==b)
        {
            cout<<"Both numbers are commensurate";
        }
        else if(a<b)
        {
            cout<<a<<" is smaller then "<<b;
        }
        else if(a>b)
        {
            cout<<a<<" is bigger then "<<b;
        }
        cout<<"\n";
        cin.get();
        return 0;
    }

_________________


Last edited by lurc on Tue Oct 09, 2007 11:22 am; edited 2 times in total
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Tue Oct 09, 2007 11:21 am    Post subject: Reply with quote

lurc wrote:
ur code shoudnt even compile.... you dont even return EXIT_SUCCESS (0)

revised script:

Code:
    #include <iostream>
    using namespace std;

    int main()
    {
        int a,b; 
        cout<<"Please enter a number\n";
        cin>>a;
        cout<<"Please enter a once more number\n";
        cin>>b;

        if(a==b)
        {
            cout<<"Both numbers are commensurate";
        }
        else if(a<b)
        {
            cout<<a<<" is smaller then "<<b;
        }
        else if(a>b)
        {
            cout<<a<<" is bigger then "<<b;
        }
        cout<<"\n";
        cin.get();
        return 0;
    }


This doesnt work for me.
This one I posted works xD.
I guess my Microsoft Visual C++ sux, eh?
Back to top
View user's profile Send private message
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Tue Oct 09, 2007 12:12 pm    Post subject: Reply with quote

It doesn't make any sence, you must return a value for int functions in VC++, else it won't compile..
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Tue Oct 09, 2007 12:17 pm    Post subject: Reply with quote

try

Code:
return EXIT_SUCCESS;


or however u spell success

assaf84 wrote:
It doesn't make any sence, you must return a value for int functions in VC++, else it won't compile..


yea, your right.

unless, for some reason his compiler is changing int main to void main

_________________
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Tue Oct 09, 2007 12:24 pm    Post subject: Reply with quote

What compiler should I use instead ?
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Oct 09, 2007 12:44 pm    Post subject: Reply with quote

VC++ is fine. You could try the Intel one if you really want though.

also, int main(void)
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Tue Oct 09, 2007 12:49 pm    Post subject: Reply with quote

ahhhrg
Only
Code:
    #include <iostream>
    using namespace std;

    int main()
    {
        cout<<"Please enter a number\n";
        int a;
        cin>>a;
        cout<<"Please enter a once more number\n";
        int b;
        cin>>b;

        if(a==b)
        {
            cout<<"Both numbers are commensurate";
         cin.get();
        }
        if(a<b)
        {
            cout<<a<<" is smaller then "<<b;
         cin.get();
        }
        if(a>b)
        {
            cout<<a<<" is bigger then "<<b;
         cin.get();
        }
        cout<<"\n";
      cin.get();
    }


Is working Sad
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Oct 09, 2007 1:00 pm    Post subject: Reply with quote

well, how is not working?
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Tue Oct 09, 2007 1:03 pm    Post subject: Reply with quote

if I use your opion It closes after I entered the 2 numbers.
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Tue Oct 09, 2007 1:09 pm    Post subject: Reply with quote

That's because you're running it from explorer so you can't see the output. start->run->cmd

Code:

cd path\to\executable
yourexecutable.exe


and you will be able to see it all
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Oct 09, 2007 1:12 pm    Post subject: Reply with quote

run it from the command line, like:

cd c:\someplace\someplace\there
program.exe

edit: damnit, beaten to it. Sad
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Tue Oct 09, 2007 1:20 pm    Post subject: Reply with quote

appalsap wrote:
That's because you're running it from explorer so you can't see the output. start->run->cmd

Code:

cd path\to\executable
yourexecutable.exe


and you will be able to see it all


Yea it's wroking in that way, thx Smile. But I justed wanted it to work w/o cmd Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites