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;
}
}
Re: A fifth noobie question-enum color?
Quote:
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
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
Re: getch() is Non-Standard
Quote:
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