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++] strcmp

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Pseudo Xero
I post too much
Reputation: 0

Joined: 16 Feb 2007
Posts: 2607

PostPosted: Thu Mar 13, 2008 8:34 pm    Post subject: [C++] strcmp Reply with quote

No matter what I try it produces compiling errors. (This is the first time I've used strcmp, though.)

Here is my code:
Code:
   char input[];
   char comp[] = "nj";
   std::cout >> "Input: ";
   std::cin << input;
   if (strcmp(comp, input) != 0) {
      std::cout >> "Strcmp returned equal. Press any key to exit... ";
      getch();
   }
   else {
      std::cout >> "Strcmp returned unequal. Press any key to exit... ";
      getch();
   }

_________________
haxory' wrote:
can't VB do anything??
windows is programmed using VB right? correct me if im wrong.

so all things in windows you have like the start menu is a windows form too.
Back to top
View user's profile Send private message
Cx
Master Cheater
Reputation: 0

Joined: 27 Jul 2007
Posts: 367

PostPosted: Thu Mar 13, 2008 10:15 pm    Post subject: Reply with quote

"input" needs a size.
cout and cin symbols are reversed (cout is <<, cin is >>).
strcmp returns 0 for equal strings.

I don't think any of your errors had to do with strcmp.

Code:
#include <iostream>
int main()
{
   char input[4];
   char comp[] = "asdf";
   std::cout << "Input: ";
   std::cin >> input;
   if (strcmp(comp, input) == 0)
   {
      std::cout << "strcmp returned equal. press any key to exit... ";
      std::cin.ignore();
      std::cin.get();
   }
   else
   {
      std::cout << "strcmp returned unequal. press any key to exit... ";
      std::cin.ignore();
      std::cin.get();
   }
   return 0;
}
Back to top
View user's profile Send private message
the_undead
Expert Cheater
Reputation: 1

Joined: 12 Nov 2006
Posts: 235
Location: Johannesburg, South Africa

PostPosted: Fri Mar 14, 2008 9:08 am    Post subject: Reply with quote

Yeah, as Cx said, it strcmp and memcmp return 0 if both are equal.
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Sun Mar 16, 2008 4:16 pm    Post subject: Reply with quote

If you are coding in C++, why not to use std::string class?
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