![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" | iBot | UNIX and Linux RSS News | 0 | 01-04-2008 12:00 PM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-19-2007 10:52 PM |
| Unix "at" / "Cron" Command New Problem...Need help | Mohanraj | UNIX for Dummies Questions & Answers | 3 | 01-26-2006 05:08 PM |
| No utpmx entry: you must exec "login" from lowest level "shell" | peterpan | UNIX for Dummies Questions & Answers | 0 | 01-18-2006 01:15 AM |
| Why ""No mountable file system" | endeavour1985 | High Level Programming | 0 | 03-02-2005 06:01 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
system("PAUSE") Problem.....
Ok, here's the situation....I have this code...
#include <iostream.h> #include <stdlib.h> int main() { cout << "\nBlah, and Blah\n\n"; system("PAUSE"); return 0; } Now, "system("PAUSE")" gets executed before "cout" does, and I have absolutely no idea why, so when I type this in instead... #include <stdio.h> #include <stdlib.h> int main() { printf ("\nBlah, and Blah\n\n"); system("PAUSE"); return 0; } ...it works just fine....it's like printf has precidence over cout, which I need to fix. So, does anyone know another way for a PAUSE using cout, and does anyone have anymore information on why this situation occurs? Thanks! Mike
__________________
I like to play Quake |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Any output to stdout/cout is buffered (unless you have set the
proper ioctl's for unbuffered output) so there is no guarantee that you will see the output when the cout << ... OR printf() is executed. If you want to guarantee that the output goes to the screen prior to executing the next statement, in C++ you can simply add " << endl" or in C you can call fflush(stdout) prior to calling "system()". Actually, the fact the printf() works is hit or miss. It may or may not work. |
|
#3
|
|||
|
|||
|
Ah...
This answered my question _perfectly_, :) thank you very much for your help, i appreciate it
Mike
__________________
I like to play Quake |
|||
| Google The UNIX and Linux Forums |