Author |
Message |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: Thu May 26, 2005 4:34 pm Post subject: Dev c++ beta 5 |
|
|
Hi I have just started C++ and i am having a problem with the dev c++ beta 5. When i try to compile and run this code, The DOS window opens up and closes immediately
EDIT: Oh nvm i think it works |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
wtd
|
Posted: Thu May 26, 2005 4:44 pm Post subject: (No subject) |
|
|
That's normal behavior. That window is created specifically to display output from your program. Your program runs very quickly, then quits, and once it's over, the window no longer has a reason to be open.
Now, if you were waiting for the user to do something, like hit enter, it would stay open. ![Smile Smile](http://compsci.ca/v3/images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: Fri May 27, 2005 3:39 pm Post subject: (No subject) |
|
|
Yep. i got that thanks!
Oh and by the ways, how do skip a line, like in turing we can
i tried
Doesn't work |
|
|
|
|
![](images/spacer.gif) |
Mazer
![](http://compsci.ca/v3/uploads/user_avatars/1323750815476d9f446d80c.png)
|
Posted: Fri May 27, 2005 4:12 pm Post subject: (No subject) |
|
|
In your case, you'd want either:
code: | cout << "[Sometexthere]\n"; |
OR
code: | cout << "blah blah blah" << endl; |
|
|
|
|
|
![](images/spacer.gif) |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: Fri May 27, 2005 4:29 pm Post subject: (No subject) |
|
|
thanks ![Very Happy Very Happy](http://compsci.ca/v3/images/smiles/icon_biggrin.gif) |
|
|
|
|
![](images/spacer.gif) |
wtd
|
Posted: Fri May 27, 2005 4:40 pm Post subject: (No subject) |
|
|
You can also always:
c++: | std::cout << std::endl; |
There's nothing special about:
std::endl is just another variable. |
|
|
|
|
![](images/spacer.gif) |
jamonathin
![](http://compsci.ca/v3/uploads/user_avatars/57683465145f851a43dd9a.gif)
|
Posted: Fri May 27, 2005 4:41 pm Post subject: (No subject) |
|
|
Yeah the \n works, and as I saw in zylum's maze proggy, and \n skips a line in Turing as well ![Surprised Surprised](http://compsci.ca/v3/images/smiles/icon_surprised.gif) |
|
|
|
|
![](images/spacer.gif) |
wtd
|
Posted: Fri May 27, 2005 4:46 pm Post subject: (No subject) |
|
|
Yes, because \n is the newline character. However, using std::endl is the more idiomatically correct C++ approach. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: Fri May 27, 2005 8:43 pm Post subject: (No subject) |
|
|
Wow \n works for turing? whew i didnt know that! cool 8)
Anyways what does std:: mean? |
|
|
|
|
![](images/spacer.gif) |
wtd
|
Posted: Fri May 27, 2005 10:13 pm Post subject: (No subject) |
|
|
MysticVegeta wrote: Anyways what does std:: mean?
"std" is the name of the standard namespace in C++. The "::" is the namespace resolution operator. It's C++'s way of saying "the variable (or function, or class, or whatever) named endl in the std namespace".
You can see this in action by creating your own namespace.
c++: | #include <iostream>
#include <string>
namespace foo
{
std::string bar("Hello world");
}
int main()
{
std::cout << foo::bar << std::endl;
return 0;
} |
|
|
|
|
|
![](images/spacer.gif) |
|