cplusplus.com cplusplus.com
cplusplus.com   C++ : Forums : Beginners : String Error
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Forums
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Articles
Lounge
Jobs

-

post  String Error

CheesyBeefy (8)
Well, in my code, a jumble of letters will appear and if the user doesn't type them in correctly, they lose. However whenever I try to check if the user inputed the correct jumble of letters, it says that jumble is an undeclared identifier. Here is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

int main()

{
	//variables
	string answer = dsahfkjd;
	string guess;
	//code
	cout << "Say " << answer << endl;
	cin >> guess;
	if(guess == answer)
	{
		cout << "Good Job!" << endl;
		system("PAUSE");
	}
	else
	{
		cout << "You lose and you suck. Haha." << endl;
		system("PAUSE");
		return (0);
	}
}


Here is the error I am receiving.

error C2065: 'dsahfkjd' : undeclared identifier

Please tell me what I am doing wrong!
|
Grey Wolf (637)
string answer = "dsahfkjd";
|
CheesyBeefy (8)
Ahh, thanks. :)

Also, how would I add a timer, such as, if they don't answer within a certain amount of time they will lose?
| Last edited on

Registered users can reply in this forum.
Home page | Privacy policy
© cplusplus.com, 2000-2008 - All rights reserved - v2.2
Spotted an error? contact us