| View previous topic :: View next topic |
| Author |
Message |
MasterChief Grandmaster Cheater Supreme
Reputation: 0
Joined: 07 Dec 2006 Posts: 1208 Location: Texas
|
Posted: Tue Apr 01, 2008 3:22 pm Post subject: |
|
|
wow i do it weird then i made it like this.
| Code: | #include <iostream.h>
int main()
{
cout << "hello world\n";
return 0;
cin>> exit;
}
And it would just wait for me to put in something before closing.
|
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Apr 01, 2008 5:03 pm Post subject: |
|
|
it would be a gift from god if that compiled.
also, cin would never be reached
|
|
| Back to top |
|
 |
MasterChief Grandmaster Cheater Supreme
Reputation: 0
Joined: 07 Dec 2006 Posts: 1208 Location: Texas
|
Posted: Tue Apr 01, 2008 9:46 pm Post subject: |
|
|
| slovach wrote: | it would be a gift from god if that compiled.
also, cin would never be reached |
my bad i meant to put
string exit;
at the top, and since the cin isnt reached it doesnt close. Until you put in a character and hit enter.
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Apr 01, 2008 10:23 pm Post subject: |
|
|
You're never going to get to cin, ever, it's just going to exit.
Also, <iostream> not <iostream.h>
Also also, exit isn't defined
|
|
| Back to top |
|
 |
MasterChief Grandmaster Cheater Supreme
Reputation: 0
Joined: 07 Dec 2006 Posts: 1208 Location: Texas
|
Posted: Wed Apr 02, 2008 12:07 am Post subject: |
|
|
| slovach wrote: | You're never going to get to cin, ever, it's just going to exit.
Also, <iostream> not <iostream.h>
Also also, exit isn't defined |
I said i meant to put string exit; at the top, but since its never defined it dont close. it wait until you put something in to close.
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Apr 02, 2008 12:21 am Post subject: |
|
|
| thewiier wrote: | | slovach wrote: | You're never going to get to cin, ever, it's just going to exit.
Also, <iostream> not <iostream.h>
Also also, exit isn't defined |
I said i meant to put string exit; at the top, but since its never defined it dont close. it wait until you put something in to close. |
You are still lost it seems, the code you posted above will never reach the input line. Your code was:
| Code: | cout << "hello world\n";
return 0;
cin>> exit; |
You are returning before even attempting to use that cin line. Thus, the cin is useless and never called.
_________________
- Retired. |
|
| Back to top |
|
 |
Negima I post too much
Reputation: 6
Joined: 22 May 2007 Posts: 2222
|
Posted: Thu Apr 03, 2008 9:36 pm Post subject: |
|
|
| Another question I have is how can I change colors in a console app? such as the text/background?
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Fri Apr 04, 2008 6:10 am Post subject: |
|
|
| Negima wrote: | | Another question I have is how can I change colors in a console app? such as the text/background? |
| Code: | #include <windows.h>
#include <iostream>
int main()
{
// Obtain Console Handle
HANDLE hConsoleHandle = GetStdHandle( STD_OUTPUT_HANDLE );
// Make Loop To Output Color Combinations
for( int x=0; x<255; x++ )
{
SetConsoleTextAttribute( hConsoleHandle, x );
std::cout << "Hello this is a quick message. :) (Color Code: " << x << ")" << std::endl;
}
// Pause And Return
std::cin.sync();
std::cin.ignore();
return 0;
} |
Will loop from 0 to 254 and show you all the combinations for each number.
_________________
- Retired. |
|
| Back to top |
|
 |
|