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 


where's the error?!?[C++]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Engineer
Expert Cheater
Reputation: 1

Joined: 25 Nov 2007
Posts: 170

PostPosted: Fri Dec 14, 2007 8:35 am    Post subject: where's the error?!?[C++] Reply with quote

i can't find it... it says the error is on line 40 (when i finish with return0)
sorry for spargetti (goto-ed) code
can someone fix the error?
Code:


//something interactive...
//by teh 1338 nub zzoozz
#include <iostream.h>

int main()
{
    int choice;
   
    Jump1:
          {
          while (choice < 50000)
          {
                cout << "Insert a number";
                cout << "from 1 to 5";
                cout << ", 0 to quit";
                cin >> choice;
                switch (choice)
                {
                       case 1:cout <<"Pfft, 1..." << endl;
                       case 2:cout <<"OoOo, 1+1=2!" << endl;
                       case 3:cout <<"O RLY? 3?!?" << endl;
                       case 4:cout <<"Mamamia! itsa 4!" << endl;
                       case 5:cout <<"Last owns all!" << endl;
                       case 0:goto Jump3;
                       default:goto Jump2;
                }
    Jump2:
          {
          cout <<"Too high!" << endl;
          goto Jump1;
          }
         
    Jump3:
          {
          cout <<"Ok, bye!" << endl;
          system("pause");
          return 0;
}
}
}
return 0}
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Fri Dec 14, 2007 10:43 am    Post subject: Reply with quote

The problem is that you have a whole lot of brackets that you don't need.
Back to top
View user's profile Send private message
Engineer
Expert Cheater
Reputation: 1

Joined: 25 Nov 2007
Posts: 170

PostPosted: Fri Dec 14, 2007 10:48 am    Post subject: Reply with quote

Flyte wrote:
The problem is that you have a whole lot of brackets that you don't need.


no, the error isnt there,i fixed like 4 errors adding brackets at the end
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Fri Dec 14, 2007 10:55 am    Post subject: Reply with quote

Missing ; after return 0. You've to do a lot to improve your code. I have to say that your code is f'ugly.
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Fri Dec 14, 2007 11:02 am    Post subject: Re: where's the error?!?[C++] Reply with quote

I wrote this up in notepad quickly, there might be an error or two.

Code:

#include <iostream.h>

int main()
{
    int choice; bool done = false;
    do  {
        std::cout << "Insert a number";
        std::cout << "from 1 to 5";
        std::cout << ", 0 to quit";
        std::cin >> choice;
        switch (choice)  {
            case 1:
                std::cout <<"Pfft, 1..." << endl; break;
            case 2:
                std::cout <<"OoOo, 1+1=2!" << endl; break;
            case 3:
                std::cout <<"O RLY? 3?!?" << endl; break;
            case 4:
                std::cout <<"Mamamia! itsa 4!" << endl; break;
            case 5:
                std::cout <<"Last owns all!" << endl; break;
            case 0:
                done = true; break;
            default:
                std::cin.sync();
                std::cout << "Invalid input." >> endl;
                break;
        }
    } while(!done);
    std::cout <<"Ok, bye!" << endl;
    std::cin.sync();
    std::cin.get();
    return 0;
}
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Fri Dec 14, 2007 3:38 pm    Post subject: Re: where's the error?!?[C++] Reply with quote

Flyte wrote:
#include <iostream.h>
Code:
#include <iostream>


Flyte wrote:
int choice;
If there's only umm.. 6 different options, why to allocate sizeof(int) blocks memory?

Flyte wrote:
std::cin >> choice;
Check if it was done successfully.

Flyte wrote:
std::cout <<"Pfft, 1..." << endl;
std::cout, but endl? I'm not seeing any using;, but I'm seeing iostream.h.

Flyte wrote:
std::cout << "Invalid input." >> endl;
Rly?

Flyte wrote:
std::cin.get();
Code:
std::cin.ignore();
std::cin.sync();


Flyte wrote:
return 0;
0 isn't always EXIT_SUCCESS.

Flyte wrote:
I wrote this up in notepad quickly, there might be an error or two.
I wrote this up in reply field quickly and drunk, there might be an error or two.

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

Joined: 03 Dec 2006
Posts: 2436

PostPosted: Fri Dec 14, 2007 3:52 pm    Post subject: Re: where's the error?!?[C++] Reply with quote

Add this code to it

//something interactive...
//by teh 1338 nub zzoozz
#include <iostream.h>

using namespace std;
int main()
{
int choice;
...
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Fri Dec 14, 2007 3:56 pm    Post subject: Re: where's the error?!?[C++] Reply with quote

HornyAZNBoy wrote:
#include <iostream.h>
using namespace std;
Nonononononono, no!
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Fri Dec 14, 2007 4:17 pm    Post subject: Reply with quote

Heh, looking back on that I probably shouldn't have made it that early in the morning.

The computer I was on didn't have a compiler... Crying or Very sad
Back to top
View user's profile Send private message
Engineer
Expert Cheater
Reputation: 1

Joined: 25 Nov 2007
Posts: 170

PostPosted: Sat Dec 15, 2007 4:26 am    Post subject: Reply with quote

dont complain about my code, im just learning c++ for like a week and 3 days...
thanks for fixing the code Wink

EDIT:Error in compile, as i still didnt learnd that namespace new codes i cant find it
also its only 1 error
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Sat Dec 15, 2007 11:26 am    Post subject: Reply with quote

Make sure you fix all of the errors Jani found.
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Sat Dec 15, 2007 4:56 pm    Post subject: Reply with quote

Flyte wrote:
Make sure you fix all of the errors Jani found.
The errors are in your code, not his :P The only error I found in his code is this:
Jani wrote:
Missing ; after return 0. You've to do a lot to improve your code. I have to say that your code is f'ugly.


PS. Iono if he's concerning your version of the program as a "fixed" one. I'd say it's a rewritten one, not fixed.
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
Page 1 of 1

 
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