A fifth noobie question-enum color?

This is a discussion on A fifth noobie question-enum color? within the C++ Programming forums, part of the General Programming Boards category; The below is also from a tutorial-the tutorial never says what its supposed to do but I would assume its ...

  1. #1
    1.b4 e5 2.a3 d5 3.d4 exd
    Join Date
    Jan 2003
    Posts
    167

    A fifth noobie question-enum color?

    The below is also from a tutorial-the tutorial never says what its supposed to do but I would assume its supposed to cout something, except it just runs and does absolutely nothing and quits

    Code:
    #include <iostream>
    
    void main()
    {
         enum color {RED, GREEN, BLUE};
         color myColor = RED;
    
         if (myColor == RED) {
              cout << "hot" << endl;
         }
         if (myColor == BLUE) {
              cout << "cold" << endl;
         }
         if (myColor == GREEN) {
              cout << "Is not easy being" << endl;
         }
    
    }

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    103

    Re: A fifth noobie question-enum color?

    Originally posted by Noobie
    The below is also from a tutorial-the tutorial never says what its supposed to do but I would assume its supposed to cout something, except it just runs and does absolutely nothing and quits

    Code:
    #include <iostream>
    
    void main()
    {
         enum color {RED, GREEN, BLUE};
         color myColor = RED;
    
         if (myColor == RED) {
              cout << "hot" << endl;
         }
         if (myColor == BLUE) {
              cout << "cold" << endl;
         }
         if (myColor == GREEN) {
              cout << "Is not easy being" << endl;
         }
    
    }
    You sound like a cute kid cribbing over small things take it easy.. relax for once ....

    Code:
    #include <iostream.h>
    
    int main() // main has to always have int as its return type
    {
         enum color {RED, GREEN, BLUE};
         color myColor = RED;
    
         if (myColor == RED) {
              cout << "hot" << endl;
         }
         if (myColor == BLUE) {
              cout << "cold" << endl;
         }
         if (myColor == GREEN) {
              cout << "Is not easy being" << endl;
         }
    
         char dummy_wait_variable;
         cin >> dummy_wait_variable; // this will temporarily pause 
                                                        //your output before u return to the code 
         return 0; // added this since you we have stated that we would return an int
    }

    // If I am not wrong, to see the output in the background, you must press Alt+F5
    Have a wonderful day.... and keep smiling... you look terrific that way
    signing off...
    shiv... as i know him

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640

    Re: A fifth noobie question-enum color?

    Code:
    #include <iostream>
    #include <conio.h> // needed for getch()
    
    using namespace std; // plz use this, dont ask why just yet
    
    int main() // Don't ever EVER EVERRRR use void main()
    {
         enum color {RED, GREEN, BLUE};
         color myColor = RED;
    
         if (myColor == RED) {
              cout << "hot" << endl;
         }
         if (myColor == BLUE) {
              cout << "cold" << endl;
         }
         if (myColor == GREEN) {
              cout << "Is not easy being" << endl;
         }
    
         getch(); // halt the program until someone presses a button
    
         return 0; return an int
    }
    Try this

  4. #4
    1.b4 e5 2.a3 d5 3.d4 exd
    Join Date
    Jan 2003
    Posts
    167
    alt-f5? background? all i have is a black dos screen-alt-f5 doesnt do a thing!

  5. #5
    Registered User
    Join Date
    Dec 2002
    Posts
    103

    getch() is Non-Standard

    Originally posted by Travis Dane

    Code:
    #include <iostream>
    #include <conio.h> // needed for getch()
    
    using namespace std; // plz use this, dont ask why just yet
    
    getch(); // halt the program until someone presses a button
    
    }
    Try this
    getch() is a non-standard function. Its preferable to code using standard functions only
    Have a wonderful day.... and keep smiling... you look terrific that way
    signing off...
    shiv... as i know him

  6. #6
    Registered User
    Join Date
    Dec 2002
    Posts
    103

    Its OK :)

    Originally posted by Noobie
    alt-f5? background? all i have is a black dos screen-alt-f5 doesnt do a thing!
    Even otherwise the program I gave you should work or the one suggested by travis
    Have a wonderful day.... and keep smiling... you look terrific that way
    signing off...
    shiv... as i know him

  7. #7
    1.b4 e5 2.a3 d5 3.d4 exd
    Join Date
    Jan 2003
    Posts
    167
    The below code was posted and does not work because a namespace name is expected and there is an unexpected }

    Code:
    #include <iostream>
    #include <conio.h> // needed for getch()
    
    using namespace std; // plz use this, dont ask why just yet
    
    getch(); // halt the program until someone presses a button
    
    }

  8. #8
    1.b4 e5 2.a3 d5 3.d4 exd
    Join Date
    Jan 2003
    Posts
    167
    The below code was posted and does not work because a namespace name is expected; unreachable code; undefined symbol an; return statement missing; and compound statement missing

    Code:
    #include <iostream>
    #include <conio.h> // needed for getch()
    
    using namespace std; // plz use this, dont ask why just yet
    
    int main() // Don't ever EVER EVERRRR use void main()
    {
         enum color {RED, GREEN, BLUE};
         color myColor = RED;
    
         if (myColor == RED) {
              cout << "hot" << endl;
         }
         if (myColor == BLUE) {
              cout << "cold" << endl;
         }
         if (myColor == GREEN) {
              cout << "Is not easy being" << endl;
         }
    
         getch(); // halt the program until someone presses a button
    
         return 0; return an int
    }

  9. #9
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640

    Re: getch() is Non-Standard

    Originally posted by shiv_tech_quest
    getch() is a non-standard function. Its preferable to code using standard functions only
    Yea, well, i think most compilers have this, otherwise just past
    a cin to halt the program, ugly but it works

  10. #10
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    *sich* try this

    Code:
    #include <iostream>
    #include <conio.h> // needed for getch()
    
    using namespace std; // plz use this, dont ask why just yet
    
    int main() // Don't ever EVER EVERRRR use void main()
    {
         enum color {RED, GREEN, BLUE};
         color myColor = RED;
    
         if (myColor == RED) {
              cout << "hot" << endl;
         }
         if (myColor == BLUE) {
              cout << "cold" << endl;
         }
         if (myColor == GREEN) {
              cout << "Is not easy being" << endl;
         }
    
         getch(); // halt the program until someone presses a button
    
         return 0;
    }
    I'm really getting the impression wheyre writing this program for you

  11. #11
    Registered User
    Join Date
    Dec 2002
    Posts
    103
    Originally posted by Noobie
    The below code was posted and does not work because a namespace name is expected and there is an unexpected }

    Code:
    #include <iostream>
    #include <conio.h> // needed for getch()
    
    using namespace std; // plz use this, dont ask why just yet
    
    getch(); // halt the program until someone presses a button
    
    }
    Gosh!!!!!!!!!!!!! Don't Rush.... Haste is Waste... plzzzzzzzz

    In the beginning of this thread, I have given the complete program, when i said it will work, i referred to the complete program that I have posted in the start.

    I had to correct travis's code and hence just included the line of code on which I had a difference of opinion with travis
    Have a wonderful day.... and keep smiling... you look terrific that way
    signing off...
    shiv... as i know him

  12. #12
    1.b4 e5 2.a3 d5 3.d4 exd
    Join Date
    Jan 2003
    Posts
    167
    well...i dont know how to compile and the tutorials I go to tell me to use code like namespace std; or getch that dont work!

  13. #13
    1.b4 e5 2.a3 d5 3.d4 exd
    Join Date
    Jan 2003
    Posts
    167
    shiv i tried using your code and it compiles but it doesnt do anything when i run it! so u told me to use alt-f5 and that doesnt do anything either and u said something about a background and where is there a background?

  14. #14
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    grrr, what compiler do you have? It doesnt seem to have anything!! i write some code that MUST work, even an a dumbass compiler

  15. #15
    1.b4 e5 2.a3 d5 3.d4 exd
    Join Date
    Jan 2003
    Posts
    167
    Well I have C++ Builder 4 except I dont know how to use it and create a .cpp which I can compile-its too fancy-but I found Borland 5.02 on the cd so Im using the latter program

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

Similar Threads

  1. Win32 Console Color Question
    By AndyBomstad in forum C++ Programming
    Replies: 4
    Last Post: 02-04-2005, 02:35 PM
  2. A question of color...(not a racial question)
    By Sebastiani in forum Windows Programming
    Replies: 7
    Last Post: 01-15-2003, 08:05 PM
  3. what does this warningmean???
    By kreyes in forum C Programming
    Replies: 5
    Last Post: 03-04-2002, 07:53 AM
  4. enum question
    By incognito in forum C++ Programming
    Replies: 1
    Last Post: 12-30-2001, 12:04 AM
  5. About Color in MFC
    By Alextrons in forum Windows Programming
    Replies: 0
    Last Post: 11-05-2001, 07:40 PM

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