• Advertisement

Archived

This topic is now archived and is closed to further replies.

OK

This topic is 5488 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I now have the Borland C++ builder 6, I looked at all the tutorials but I still don''t no what to do I did the //my first program in C++ #include <iostream.h> int main() { cout << "Hello World!"; return 0; } but nothing isn''t showing up could somebody please help me

Share this post


Link to post
Share on other sites
Advertisement
Ok so you are saying that I should type this

//my first program in C++

#include <iostream.h>

int main()
{
cout << "Hello World!"end1;

return 0;
}

Share this post


Link to post
Share on other sites
actually he meant:

cout << "Hello World!" << endl;
// notice the << before endl ?



"No lies of sugar can sweeten the sournes of reality"

}+TITANIUM+{ A.K.A. DXnewbie[onMIRC]

Share this post


Link to post
Share on other sites
No you should type:


  
#include <iostream.h>

int main()
{
cout << "Hello World" << endl;
return 0;
}


Note that that it is ENDL, just in lowercase.
And maybe you want to run it from the command line (start->run, type cmd (or command on win9x/me), press enter, switch to your progs folder using doscommands).
Alternative you can do a .bat file with the content:

exename.exe
pause

and run that bat file.
You can also put an input at the end of the program or system("PAUSE"); before the return 0;.

[My Lousy Page | Kings Of Chaos | Vampires | email.me]

Share this post


Link to post
Share on other sites
No, you should type:

        

#include <iostream>


int main()
{
std::cout << "Hello World!" << std::endl;
return 0;
}


:D

Edit: eek! nice catch Arkainium, cheers

Henrym
My Site

[edited by - henrym on February 10, 2003 2:37:06 AM]

Share this post


Link to post
Share on other sites
No, you should type:


  #include <iostream>

int main()
{
std::cout << "Hello World!" << std::endl;
return 0;
}




[edited by - Arkainium on February 8, 2003 5:31:57 PM]

Share this post


Link to post
Share on other sites
can you...

cout << "Hello World!" << flush;

?

I'm not at a comp with a compiler so...thanks

[edited by - kordova on February 8, 2003 10:56:50 PM]

Share this post


Link to post
Share on other sites
I would go
--------------------------------------------
#include <iostream.h>

int main()
{
cout << "Hello world!" << endl;

return 0;
}
--------------------------------------------

That should work. But that std::cout might have to do if you're using Borland. I don't know if it matters.

Try this:
--------------------------------------------
#include <iostream>
namespace std;

int main()
{
cout << "Hello world!" << endl;

return 0;
}
--------------------------------------------

If that don't work...I ain't gotta clue what you're doin. Maybe you're using your compiler incorrectly.

Moose

[edited by - moose_2006 on February 8, 2003 10:33:30 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by moose_2006
Try this:
--------------------------------------------
#include <iostream>
namespace std;

int main()
{
cout << "Hello world!" << endl;

return 0;
}
--------------------------------------------


You want using namespace std; there.

Either of these should work:

  
// Number 1:

#include <iostream>

int main()
{
std::cout << "Hello, world!" << std::endl;

return 0;
}

// Number 2:

#include <iostream>
using namespace std;

int main()
{
cout << "Hello, world!" << endl;

return 0;
}

If you are just starting to learn C++, cybersniper, then I would recommend buying a good book.

[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]

Share this post


Link to post
Share on other sites
no you should do

    
#include <iostream>

int main()
{
cout.write("Hello, World!", 13) << endl;
return 0;
}


EDIT: fixed arglist

[edited by - sneftel on February 10, 2003 4:34:45 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by Sneftel
. . .



quote:

ostream_type& write(const char_type* s, streamsize n );

Obtains characters to insert from successive locations of an array whose first element is designated by s. Characters are inserted until either of the following occurs:

n characters are inserted
Inserting in the output sequence fails

In the second case the function calls the basic_ios member function setstate(badbit). The function returns *this.



If your example actually works, I don't imagine it is very portable.

[edited by - smart_idiot on February 10, 2003 4:28:39 AM]

Share this post


Link to post
Share on other sites
You''re absolutely right; it''s been a while since I had much use for ostream::write().


Don''t listen to me. I''ve had too much coffee.

Share this post


Link to post
Share on other sites
Ah, well i see two potential problems. Problem A: You didn''t create the right type of project and it''s not compiling/linking. You have to use console wizard to create a console mode application.

Potential problem 2. The program is running properly, but it runs so quickly that the Hello world disappears instantly when the program is done. To stop that, just do something like

int a;
cin >> a;

This will keep everything on screen until the program terminates.

Share this post


Link to post
Share on other sites

  • Advertisement