• Log in or sign up for an account here: https://www.sythe.org/login

Someone help me please =(

Status
Not open for further replies.

WoW Sucks

Grand Master

Banned
Joined
Jan 21, 2007
Sythe Gold
0
Messages
3,708
Age
36
Location
England
Ok, well i started learning C++ yesterday and i was doing fine untill i started a text game, which went wrong =(

Code:
#include <iostream>

using namespace std;



void main()
{
	char name;

	cout << "Welcome To The Adventure Text Game" << "\n";

	cout << "Please Choose a name: " << name;
	cin >> name;

		cout << name << "\n";



}

This is what happens when i compile it:

grrrrrrrrz5.jpg


How can i make those stupid characters go away, and make it print the name you insert?

Thanks.
 
Ok, well i started learning C++ yesterday and i was doing fine untill i started a text game, which went wrong =(

Code:
#include <iostream>

using namespace std;



void main()
{
	char name;

	cout << "Welcome To The Adventure Text Game" << "\n";

	cout << "Please Choose a name: "; [b]//<< name;[/b]
	cin >> name;

		cout << name << "\n";



}

This is what happens when i compile it:

grrrrrrrrz5.jpg


How can i make those stupid characters go away, and make it print the name you insert?

Thanks.

You tried to display a character before it was defined by the user (see commented out part) ;P
 
Printing a 'garbage value', as stated by K&R.
 
Yeah they've already both told you Dave but if you need more help next time look for me on MSN. I'm not a C++ guru but no offense, I'm better than you. =P
 
Umm im pretty sure this thread is from november >_>

Lockage please!
 
Status
Not open for further replies.
Runescape Gamblingrunescape gambling
Back
Top