?
Solved

Unsign char pointer comparison

Posted on 2003-11-10
3
Medium Priority
?
1,060 Views
Last Modified: 2010-10-05
Hi,
I have a dilemma. I would like to compare images if it is the same. My idea of this is if the image is the same don’t copy it, else do.

Basically, theApp.m_pBitmap is unsigned char *m_pBitmap;

I want to copy that and compare it again.
This is what I did.
sign char *img = NULL;

strcpy(img, (char *) theApp.m_pBitmap)
if (strcmp(img,(char *)theApp.m_pBitmap)!=0)
{
//do something;
}
Did compare it correctly? What did I do wrong?

Thank all
0
Comment
Question by:musicc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Expert Comment

by:cindy_k
ID: 9718286
I would use memcmp instead.  StrCmp is going to look for Nulls and you won't want that.

int  memcmp ( const void * buffer1, const void * buffer2, size_t num );

Hope this helps.
Cynthia
0
 
LVL 5

Accepted Solution

by:
rendaduiyan earned 105 total points
ID: 9720808
Or you can use STL equal to do so.
template<class InputIterator1, class InputIterator2>
   bool equal
(
      InputIterator1 _First1,
      InputIterator1 _Last1,
      InputIterator2 _First2
   );
if(true == equal(img1, img1+size, img2))
....
0
 

Author Comment

by:musicc
ID: 9754695
thank you for helping me.
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question