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 


[Help, C++] Error, strings
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Jaak
Expert Cheater
Reputation: 0

Joined: 02 Jul 2008
Posts: 176

PostPosted: Fri Jul 25, 2008 6:31 pm    Post subject: [Help, C++] Error, strings Reply with quote

Hey guys, I'm currently working on strings and I keep getting an error.
Here is my example code, im just using this so that i know what to do for further use for strings, i know this is just gonna print the string and it servers no purpose but i just needa know so i know what to do with other stuff
My code:

Code:

#include "iostream.h"
#include "stdlib.h"
#include "string.h"
int main
{
string mystring;
mystring == 'abcdef';
cout << mystring << endl;

return 0;
}



Error1: 'main' : looks like a function definition, but there is no parameter list; skipping apparent body

Error2: error C2015: too many characters in constant

for some reason the string in string mystring; doesn't highlight blue like when doing an int or char. is there another word for strings. also should i be declaring an int for main or is there something else, ty =]
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Fri Jul 25, 2008 6:37 pm    Post subject: Reply with quote

1. Main is a function so you must put a () after it (ie. int main() )
2. single quote's mean character, while double quote's mean string.
3. == is a condition for equality, while = is for assignment.

edit:
4. #include <iostream> / #include <string>
5. std::string mystring; std::cout << ... or using namespace std (even tho its pointless for 2 things)

mystring = "abcdef";

should work.

_________________


Last edited by lurc on Fri Jul 25, 2008 6:40 pm; edited 3 times in total
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: Fri Jul 25, 2008 6:38 pm    Post subject: Reply with quote

Code:
int main( void )


Neutral
Back to top
View user's profile Send private message MSN Messenger
Jaak
Expert Cheater
Reputation: 0

Joined: 02 Jul 2008
Posts: 176

PostPosted: Fri Jul 25, 2008 6:39 pm    Post subject: Reply with quote

@lurc I made those changes and i still get 1 error,

error C2470: 'main' : looks like a function definition, but there is no parameter list; skipping apparent body
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Jul 25, 2008 6:40 pm    Post subject: Reply with quote

Try:

Code:

#include <iostream>
#include <string>

int main() {
   std::string mystring = "abcdef";
   std::cout<<mystring;
   return 0;
}


Btw, find a new tutorial, yours is outdated.

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Fri Jul 25, 2008 6:40 pm    Post subject: Reply with quote

look at my edits.
and noz's.

_________________
Back to top
View user's profile Send private message
Jaak
Expert Cheater
Reputation: 0

Joined: 02 Jul 2008
Posts: 176

PostPosted: Fri Jul 25, 2008 6:42 pm    Post subject: Reply with quote

Edit: i got it to work, thanks guys =]
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Jul 25, 2008 6:43 pm    Post subject: Reply with quote

oib111 wrote:
Try:

Code:

#include <iostream>
#include <string>

int main() {
   std::string mystring = "abcdef";
   std::cout<<mystring;
   return 0;
}


Btw, find a new tutorial, yours is outdated.

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Jaak
Expert Cheater
Reputation: 0

Joined: 02 Jul 2008
Posts: 176

PostPosted: Fri Jul 25, 2008 6:46 pm    Post subject: Reply with quote

oib111 wrote:
oib111 wrote:
Try:

Code:

#include <iostream>
#include <string>

int main() {
   std::string mystring = "abcdef";
   std::cout<<mystring;
   return 0;
}


Btw, find a new tutorial, yours is outdated.


I'm using C++ all in one desk reference for Dummies 7books in 1 edition Razz. I hope i can still use it Confused was printed in 2003 so it doesn't seem that old. Also the program keeps closing, can i use

Code:

system("PAUSE");


thanks
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Jul 25, 2008 6:49 pm    Post subject: Reply with quote

Well it uses bad methods such as including header files with "" instead of <> and using iostream.h and string.h (those are outdated). And try to avoid using system(""). Use this to pause:

Code:

std::cin.sync();
std::cin.get();

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Jaak
Expert Cheater
Reputation: 0

Joined: 02 Jul 2008
Posts: 176

PostPosted: Fri Jul 25, 2008 6:54 pm    Post subject: Reply with quote

oib111 wrote:
Well it uses bad methods such as including header files with "" instead of <> and using iostream.h and string.h (those are outdated). And try to avoid using system(""). Use this to pause:

Code:

std::cin.sync();
std::cin.get();


Ok , 1. I HAVE to do #include "iostream.h" Im using Visual C++ 2008 and you have seperate file that has #include <iostream> in it and iostream.h is the file name. It's not that im using iostream.h <.<

Also, i used
cin.sync();
cin.get();

and works great, thanks Smile
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Jul 25, 2008 6:57 pm    Post subject: Reply with quote

Your welcome. But look, you don't have to use #include "iostream.h" in VC++ 2008. Just replace these lines of code:

Code:

#include "iostream.h"
#include "string.h"


with these lines of code:

Code:

#include <iostream>
#include <string>

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Jaak
Expert Cheater
Reputation: 0

Joined: 02 Jul 2008
Posts: 176

PostPosted: Fri Jul 25, 2008 7:04 pm    Post subject: Reply with quote

oib111 wrote:
Your welcome. But look, you don't have to use #include "iostream.h" in VC++ 2008. Just replace these lines of code:

Code:

#include "iostream.h"
#include "string.h"


with these lines of code:

Code:

#include <iostream>
#include <string>



Tried before and doesn't work =O
When I make my new project it has 3 folders, headers, resource files, and source files.

in headers i have to make 3 header files with all the headers and i write it there as #include <iostream>

but when i got my main source file, i have to write with " " to tell it to include that header file, then it reads what to include. idk why but thats how i have to do it <.< If i don't, i get compiling errors. Confused
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Jul 25, 2008 7:13 pm    Post subject: Reply with quote

Lol. You need to learn how to use VC++. Always create empty projects. Hit Ctrl+Shift+N. Go to Win32 section. Choose Console. Put in a name and hit next, hit next again. Then select "Empty Project" and hit next. Now right click on the Source folder and click Add New File. Choose a cpp file and name it whatever you want. Then put in:

Code:

#include <iostream>
#include <string>

int main() {
   std::string mystring = "abcdef";
   std::cout<<mystring;
   std::cin.sync();
   std::cin.get();
   return 0;
}

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Jaak
Expert Cheater
Reputation: 0

Joined: 02 Jul 2008
Posts: 176

PostPosted: Fri Jul 25, 2008 7:25 pm    Post subject: Reply with quote

oib111 wrote:
Lol. You need to learn how to use VC++. Always create empty projects. Hit Ctrl+Shift+N. Go to Win32 section. Choose Console. Put in a name and hit next, hit next again. Then select "Empty Project" and hit next. Now right click on the Source folder and click Add New File. Choose a cpp file and name it whatever you want. Then put in:

Code:

#include <iostream>
#include <string>

int main() {
   std::string mystring = "abcdef";
   std::cout<<mystring;
   std::cin.sync();
   std::cin.get();
   return 0;
}



That's what i've done everytime. Rolling Eyes It doesn't matter to me as long as it does what it's suppost to <.<
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
Goto page 1, 2  Next
Page 1 of 2

 
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