Integer displaying crazy numbers issue

This is a discussion on Integer displaying crazy numbers issue within the C++ Programming forums, part of the General Programming Boards category; Code: #include <iostream> #include <string> using namespace std; int main() { int gold, loseorgain; gold = 1000; start: cout<<"Enter 1 ...

  1. #16
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    int main()
    {
     int gold, loseorgain;
     gold = 1000;
     start:
     cout<<"Enter 1 to gain gold, or 2 to lose gold.";
     cin>> loseorgain;
     cin.ignore();
     if (loseorgain==1)
      gold+= 10;
     else if (loseorgain==2)
      gold-= 10;
     return 0;
    }
    This code compiles with no errors and has only minor grammar-type changes from your original.

  2. #17
    Registered User
    Join Date
    Dec 2004
    Posts
    48
    I figured it out...it was mainly the int main() situation, with just a couple minor syntax errors...once again, thanks for the help

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Crazy loss of focus issue (i think)
    By AtomRiot in forum C# Programming
    Replies: 2
    Last Post: 06-18-2007, 03:35 PM
  2. Replies: 6
    Last Post: 04-12-2002, 08:33 AM
  3. Homework help
    By Jigsaw in forum C++ Programming
    Replies: 2
    Last Post: 03-06-2002, 04:56 PM
  4. A (complex) question on numbers
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 02-03-2002, 05:38 PM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21