![]() |
Simple question! Strings!
Hello, I'm making a text based game with C++, and my book never covered strings, (not where I am) and I am trying to do a simple program that gets a name from a user, and it prints it back out:
:
#include <iostream>Thanks! Arnack |
replace
:
cout << string;with :
cout << name;Name refers to the variable name, "string" refers to the type of the variable. |
Nevermind, I got it working. Thanks so much man! I might be putting some more questions up in this thread.. hopefully that isn't a hassle for you all!
-Arnack |
Okay, can anyone tell me how to print an int that creates a random number from 10-20 or something like that?
Kinda like a random number generator... Thanks! |
Unless you have a really non-compliant compiler you need to either put some scope resolution on cout (std::cout) or add a "using" directive. As a newbie, I will tell you that you need to test your input (cin) for success. If you aren't a newbie, then your code is just schlocky. I have no way to decide, at this point.
You might elucidate on the things you implemented to fix it. The forum is for the benefit of others who might have similar questions. It won't kill you to contribute, as opposed to just saying, "Oh, geez, Mom, I fixed it!!!". As for your second question, check the documentation for "rand" and apply some rudimentary math skills. |
Thank you, I will check it out.
|
Okay, having some trouble, again.
:
#include <stdio.h> |
|
Thanks Prm!
Okay, last question, pretty simple. How do I slow the time of when cout starts? Like I want 10 seconds before one cout is actually processed.. anyway? |
Quote:
:
void sleep(int delay) |
| All times are GMT -5. The time now is 3:10 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC