| View previous topic :: View next topic |
| Author |
Message |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
|
| Back to top |
|
 |
tdenisenko Grandmaster Cheater
Reputation: 0
Joined: 23 Oct 2007 Posts: 799 Location: Turkey
|
Posted: Tue May 06, 2008 3:00 pm Post subject: |
|
|
| Wiccaan wrote: | tdenisenko: Read up more on the basics, you don't seem to be understanding the syntax of things yet. www.cplusplus.com has a nice tutorial for the basics which I suggest you read.  |
ok i built it without error but when i try to run it, it closes so fast:
The thread 'Win32 Thread' (0x11c4) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x178c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1480) has exited with code 0 (0x0).
The program '[4528] hello.exe: Native' has exited with code 0 (0x0).
The program '[4528] hello.exe: Managed' has exited with code 0 (0x0).
EDIT: ok it shows me the text for less then 1 sec but it shows
_________________
Last edited by tdenisenko on Tue May 06, 2008 3:06 pm; edited 1 time in total |
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Tue May 06, 2008 3:05 pm Post subject: |
|
|
| Code: | #include <iostream>
using namespace std;
int main( void )
{
cout << "Hello Everybody!\n";
cin.ignore();
cin.get();
return 0;
} |
This problem is all over this forum and in my cTut i touched up on this, please look around. You have to use either cin.ignore(); cin.get(); or getch();
The program '[4528] hello.exe: Native' has exited with code 0 (0x0).
The program '[4528] hello.exe: Managed' has exited with code 0 (0x0).
This is good. It means that the program ran and returned 0 which is what you told it to do. It's just it ran and didn't pause for you, which is what those codes do. They wait for user input.
Edit: get the fucking shit out of your siggy. That's a trainer that you just edited the strings too. I don't like when people leech like that and claim shit as their own when they can't even get C apps working. Don't disrespect the community by doing that.
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
Posted: Tue May 06, 2008 3:37 pm Post subject: |
|
|
| blankrider wrote: | | Code: | #include <iostream>
using namespace std;
int main( void )
{
cout << "Hello Everybody!\n";
cin.ignore();
cin.get();
return 0;
} |
This problem is all over this forum and in my cTut i touched up on this, please look around. You have to use either cin.ignore(); cin.get(); or getch();
The program '[4528] hello.exe: Native' has exited with code 0 (0x0).
The program '[4528] hello.exe: Managed' has exited with code 0 (0x0).
This is good. It means that the program ran and returned 0 which is what you told it to do. It's just it ran and didn't pause for you, which is what those codes do. They wait for user input.
Edit: get the fucking shit out of your siggy. That's a trainer that you just edited the strings too. I don't like when people leech like that and claim shit as their own when they can't even get C apps working. Don't disrespect the community by doing that. |
| Code: | std::cin.sync();
std::cin.ignore(); |
Would be the preferred method to pause with a clean and clear buffer.
_________________
- Retired. |
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Tue May 06, 2008 3:43 pm Post subject: |
|
|
Well i use ignore and get xP
_________________
|
|
| Back to top |
|
 |
Typhoon808 Expert Cheater
Reputation: 0
Joined: 27 Mar 2008 Posts: 175 Location: Wales
|
Posted: Tue May 06, 2008 4:53 pm Post subject: |
|
|
| Code: |
#include <iostream>
using namespace std;
int input;
int answer;
int main()
{
system("cls");
cout<<"Enter a number:"<<endl;
cin>>input;
answer = input * 2;
cout<<input<<" * 2 = "<<answer<<endl;
return 0;
}
|
Something like that should work just fine.
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Tue May 06, 2008 4:59 pm Post subject: |
|
|
| Erm, why have you placed that pointless system call at the top?
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue May 06, 2008 5:04 pm Post subject: |
|
|
| noz3001 wrote: | | Erm, why have you placed that pointless system call at the top? |
what if the screen is not clear enough? think of the consequences.
|
|
| Back to top |
|
 |
Typhoon808 Expert Cheater
Reputation: 0
Joined: 27 Mar 2008 Posts: 175 Location: Wales
|
Posted: Tue May 06, 2008 5:04 pm Post subject: |
|
|
| I use it to clear the CMD window of previous commands before running the program through CMD.
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue May 06, 2008 5:05 pm Post subject: |
|
|
| Typhoon808 wrote: | | I use it to clear the CMD window of previous commands before running the program through CMD. |
There wouldn't be anything.
|
|
| Back to top |
|
 |
Typhoon808 Expert Cheater
Reputation: 0
Joined: 27 Mar 2008 Posts: 175 Location: Wales
|
Posted: Tue May 06, 2008 5:09 pm Post subject: |
|
|
| It still shows up for me. I've always had a problem with running things through CMD. They never clear the window before continuing. Sorry, it's a habit of mine.
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue May 06, 2008 5:14 pm Post subject: |
|
|
| There's a shitload of overhead and it's generally very slow to do. Kick the habit
|
|
| Back to top |
|
 |
Cx Master Cheater
Reputation: 0
Joined: 27 Jul 2007 Posts: 367
|
Posted: Tue May 06, 2008 8:37 pm Post subject: |
|
|
| slovach wrote: | | noz3001 wrote: | | Erm, why have you placed that pointless system call at the top? |
what if the screen is not clear enough? think of the consequences. |
I lol'd.
_________________
armed with this small butterfly net
i will face the world alone
& never be lonely. |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
Posted: Wed May 07, 2008 12:12 am Post subject: |
|
|
| slovach wrote: | | Typhoon808 wrote: | | I use it to clear the CMD window of previous commands before running the program through CMD. |
There wouldn't be anything. |
If its a console app, it could be loaded through dos and have the previous dos text still in the window. I would, however, suggest not using system() for anything.
Clearing without system:
| Code: | #include <windows.h>
#include <iostream>
int main( int argc, char* argcv[] )
{
UNREFERENCED_PARAMETER( argc );
UNREFERENCED_PARAMETER( argcv );
//
// Clear Console Buffer
//
CONSOLE_SCREEN_BUFFER_INFO pConsoleBufferInfo;
COORD cCoords = {0};
GetConsoleScreenBufferInfo( GetStdHandle(STD_OUTPUT_HANDLE), &pConsoleBufferInfo );
FillConsoleOutputCharacter( GetStdHandle(STD_OUTPUT_HANDLE), 32, pConsoleBufferInfo.dwSize.X*pConsoleBufferInfo.dwSize.Y, cCoords, NULL );
SetConsoleCursorPosition( GetStdHandle(STD_OUTPUT_HANDLE), cCoords );
//
// Some output for the hell of it...
//
std::cout << "Some output..." << std::endl;
//
// Pause Then Return
//
std::cin.sync();
std::cin.ignore();
return 0;
} |
_________________
- Retired. |
|
| Back to top |
|
 |
Typhoon808 Expert Cheater
Reputation: 0
Joined: 27 Mar 2008 Posts: 175 Location: Wales
|
Posted: Wed May 07, 2008 3:26 am Post subject: |
|
|
| Thanks alot, Wiccaan. I'll be sure to use this.
|
|
| Back to top |
|
 |
|