Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Dev c++ beta 5
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
MysticVegeta




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: 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
MysticVegeta




PostPosted: 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
code:
put " "

i tried
code:
cout<<"";


Doesn't work
Mazer




PostPosted: 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;
MysticVegeta




PostPosted: Fri May 27, 2005 4:29 pm   Post subject: (No subject)

thanks Very Happy
wtd




PostPosted: 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:

code:
<< std::endl


std::endl is just another variable.
jamonathin




PostPosted: 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
wtd




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
MysticVegeta




PostPosted: 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?
wtd




PostPosted: 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;
}
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: