Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C++ String [Solved]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
zhanfeng123
How do I cheat?
Reputation: 0

Joined: 20 Jan 2008
Posts: 9

PostPosted: Tue Dec 30, 2008 12:27 pm    Post subject: C++ String [Solved] Reply with quote

Code:
#include <iostream>
#include <string>

int main(int argc, char *argv[])
{
   string word = "Hello There.";

   cout<<word <<"\n";
   cin.get();

   return 0;
}


Error
Code:
c:\documents and settings\user\my documents\visual studio 2008\projects\c++string\c++string\c++string.cpp(6) : error C2065: 'string' : undeclared identifier


The compiler does not seem to recognize the declaration of a string type. Any solution to this?

Thanks in advance.


Last edited by zhanfeng123 on Tue Dec 30, 2008 2:09 pm; edited 1 time in total
Back to top
View user's profile Send private message
manc
Grandmaster Cheater
Reputation: 1

Joined: 16 Jun 2006
Posts: 551

PostPosted: Tue Dec 30, 2008 12:41 pm    Post subject: Reply with quote

try declaring it first, then assigning it letters

string word;


then in your function..

word = "Hello there."

_________________
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Tue Dec 30, 2008 12:52 pm    Post subject: Reply with quote

string is declared in the namespace std, so use std::string or add "using namespace std".
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Tue Dec 30, 2008 12:55 pm    Post subject: Reply with quote

Code:
std::string word = "Hello There.";


Edit: Evil Symbol is evil Sad
Back to top
View user's profile Send private message
zhanfeng123
How do I cheat?
Reputation: 0

Joined: 20 Jan 2008
Posts: 9

PostPosted: Tue Dec 30, 2008 2:09 pm    Post subject: Reply with quote

Symbol wrote:
string is declared in the namespace std, so use std::string or add "using namespace std".


Thanks it worked. I forgot to put using namspace std nowonder my code seems to be missing something ;p
Back to top
View user's profile Send private message
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Tue Dec 30, 2008 3:52 pm    Post subject: Reply with quote

Urhm, try using char instead of string.
Back to top
View user's profile Send private message
Travis13
Expert Cheater
Reputation: 0

Joined: 17 Feb 2007
Posts: 199

PostPosted: Tue Dec 30, 2008 5:17 pm    Post subject: Reply with quote

_void_ wrote:
Urhm, try using char instead of string.


LOL..........i thought u were like "uber pro" yet u didnt catch this mistake?

using namespace std; // one of the first things u learn in c++

and i didnt get to the thread fast enough so thats why i couldnt correct it Smile

_________________
Learning C++, trying, failing, never gonna give up tho Razz
Back to top
View user's profile Send private message MSN Messenger
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Tue Dec 30, 2008 5:34 pm    Post subject: Reply with quote

Travis13 wrote:
_void_ wrote:
Urhm, try using char instead of string.
LOL..........i thought u were like "uber pro" yet u didnt catch this mistake?
.._void_ über pro.. :D

You may also use the default constructor instead of using = :
Code:
std::string word("Hello there.");
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Tue Dec 30, 2008 5:57 pm    Post subject: Reply with quote

_void_ wrote:
Urhm, try using char instead of string.


string.c_str()
Back to top
View user's profile Send private message MSN Messenger
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Tue Dec 30, 2008 7:00 pm    Post subject: Reply with quote

Travis13 wrote:
_void_ wrote:
Urhm, try using char instead of string.


LOL..........i thought u were like "uber pro" yet u didnt catch this mistake?

using namespace std; // one of the first things u learn in c++

and i didnt get to the thread fast enough so thats why i couldnt correct it Smile

What? I already know that... I didn't say it because Reak already explained it. I meant use char* instead of string...
Back to top
View user's profile Send private message
igoticecream
Grandmaster Cheater Supreme
Reputation: 0

Joined: 23 Apr 2006
Posts: 1807
Location: 0x00400000

PostPosted: Tue Dec 30, 2008 9:36 pm    Post subject: Reply with quote

typedef char string[MAX_LONG_]; should solve it too (define MAX_LONG_)
_________________
+~
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites