Help!

Write your question here.
I'm currently learning C++ my reading a book, and I copied some code but it doesn't seem to work, could you awesome people help a young kid who wants to follow his dream?
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <string>

int main()
{
	std::cout << "Please enter your first name: ";

	std::string name;
	std::cin >> name;

	std::cout << "Hello, " << name << "!" << std::endl;
	return 0;
}
What doesn't seem to work?

The code is OK according to me.
> but it doesn't seem to work

You need to give more information.

What happens when you try to run the program?

Does this program 'work'?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <string>

int main()
{
    std::cout << "Please enter your first name: ";

    std::string name;
    std::cin >> name;

    std::cout << "Hello, " << name << '\n' ;

    std::cout << "Enter any character to quit program " ;
    char c ;
    std::cin >> c ;
}
When I press the green triangle selected to 'Debug'
I get this.

This project is out of date.
Would you like to build it?

I press Yes, then it takes me to

There were build errors. Would you like to continue and run the last successful build?

I press Yes, it says

Unable to open program
I started this out on Visual C++ 2010 Express, pressed 'New Project', then chose Win32 console application for my new project.
There were build errors. Would you like to continue and run the last successful build?


You want to press NO here and go look at the errors, then fix them.
Ok, I kinda fixed it. But I don't understand. I copied this directly from 'Accelerated C++'. Maybe the book is out dated on it's content?
As C++ wanted me to, I added
#include "StdAfx.h"
According to the book, the console should show me this message

Please enter your first name:

And when I do and press enter, the console shut downs, when its supposed to show this message

Hello, (name)!
To make the program wait, aqdd the last three lines in main() from
http://www.cplusplus.com/forum/beginner/107873/#msg585656


Topic archived. No new replies allowed.