Setting a word as a varible

I'm writing a word guessing game and i'm a bit rusty with my C++. What i can't seem to remember is how do i set a word as a varible. I mean do i use a string? I can't remember for the life of me.
1
2
3
std::string hello = "Hello, World";
//or
char hi = "Hello, World";
Last edited on
You mean char*
Yes, a string would be the best way if it is just one word, otherwise use a character point like garob said.

STRING EXAMPLE:
1
2
3
4
5
6
7
8
9
#include <iostream>
#include <string>

using namespace std;

int main()
{
     string guess = "Guess";
}


CHAR POINTER EXAMPLE:
1
2
3
4
5
6
7
8
9
#include <iostream>
#include <string>

using namespace std;

int main()
{
     char* guess = "Guess This";
}


That should work for you!
Or you could just use a string for either one?

 
std::string guess = "Guess this";
Topic archived. No new replies allowed.