markiemrboo Posted July 12, 2005 Posted July 12, 2005 Yuppers, but don't try to printf() it. It doesn't like that Share this post Link to post Share on other sites More sharing options...
Archerzz Posted July 12, 2005 Posted July 12, 2005 printf()? Share this post Link to post Share on other sites More sharing options...
markiemrboo Posted July 12, 2005 Posted July 12, 2005 printf("Hello World\n"); Share this post Link to post Share on other sites More sharing options...
martymcfly Posted July 12, 2005 Posted July 12, 2005 (edited) std::cout <<"Hello World\n"; right? Just wondering, I just began learning C++. dont bash me for being a n00b. edit: so would this be a valid program? #include <iostream> void didit() { std::cout <<"I did it\n"; } main () { std::cout <<"Hello World\n"; didit(); } Edited July 12, 2005 by martymcfly Share this post Link to post Share on other sites More sharing options...
Verran Posted July 12, 2005 Posted July 12, 2005 ok if i had this string string moo = "Hello World" if i wanted to print that i would type cout << moo; right? 508088[/snapback] Ah, the old "Hello World" string.... The true sign of someone learning a new language Share this post Link to post Share on other sites More sharing options...
Archerzz Posted July 12, 2005 Posted July 12, 2005 ok, what I'm trying to do is write a program that will sing 99 bottles of beer, on the wall 99 bottles of beer you take one down pass it around 98 bottles of beer on the wall ... so far what all I have gotten is friggin strings undeclared anyone see what errors they are talking about? #include <iostream> #include <string> int main() { int n = 99; string S1 = " Bottles of beer"; string S2 = ", On the wall"; string S3 = "You take one down, pass it around"; while ( n > 0) { cout << n << S1 << S2 << endl; cout << n << S1 << endl; cout << S3 << endl; n--; } cout << "No more bottles of beer on the wall!" return 0; } Share this post Link to post Share on other sites More sharing options...
markiemrboo Posted July 12, 2005 Posted July 12, 2005 ok, what I'm trying to do is write a program that will sing 99 bottles of beer, on the wall 99 bottles of beer you take one down pass it around 98 bottles of beer on the wall ... so far what all I have gotten is friggin strings undeclared anyone see what errors they are talking about? #include <iostream> #include <string> int main() { int n = 99; string S1(" Bottles of beer"); string S2(", On the wall"); string S3("You take one down, pass it around"); while ( n > 0) { cout << n << S1 << S2 << endl; cout << n << S1 << endl; cout << S3 << endl; n--; } cout << "No more bottles of beer on the wall!" return 0; } 508110[/snapback] I just told you how to use strings, and it didn't involve brackets string S1 = " Bottles of beer"; string S2 = ", On the wall"; string S3 = "You take one down, pass it around"; You need that using namespace std; thing too if you want to use "string" You missed a ; on the cout before return 0; btw Share this post Link to post Share on other sites More sharing options...
Archerzz Posted July 12, 2005 Posted July 12, 2005 i noticed the bracket thing after i posted it I went and changed it shortley after but not soon enough and that using namespace std; thing would fall under the catagory of nice to know sooner ok lets see how this works out now... WOOOT it worked Share this post Link to post Share on other sites More sharing options...
martymcfly Posted July 12, 2005 Posted July 12, 2005 yay, mine compiled! Share this post Link to post Share on other sites More sharing options...
markiemrboo Posted July 12, 2005 Posted July 12, 2005 i noticed the bracket thing after i posted it I went and changed it shortley after but not soon enough and that using namespace std; thing would fall under the catagory of nice to know sooner ok lets see how this works out now... WOOOT it worked 508116[/snapback] haha. It's all good! If uhm.. anyone wants to search BSD man pages for C functions and their documentation, like printf() ... I just installed a man page to HTML thing, which can be found at: http://bone.bone.servebeer.com/cgi-bin/man.cgi Stick "printf" in the topic box and be amazed!! Quite neat. I'll probably use it anyway, saves me logging in via SSH all the time Share this post Link to post Share on other sites More sharing options...
Archerzz Posted July 12, 2005 Posted July 12, 2005 I am definatly bookmarking that beast now I can learn what yit means :thumbs-up: Share this post Link to post Share on other sites More sharing options...
markiemrboo Posted July 12, 2005 Posted July 12, 2005 Might have to play about with it and see if I can get it to just show the programming manual pages though. Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now