Solved

Compare LPCWSTR's and store the most recent

Posted on 2008-10-03
2
974 Views
Last Modified: 2013-12-14
Here is pseudocode:

static LPCWSTR previous;

VOID myfunc(LPCWSTR input){

  if( (wcslen(previous) != wcslen(input)) || (wcscmp(previous, input) != 0)){
    //they are different - do something
  }

  previous = input;
}

This is not working... What can I do to get this to work? Thanks!
0
Comment
Question by:Koderz
2 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 250 total points
ID: 22638528
previous will always be equal to input, since both points to the same memory portion, better you do:

static WCHAR previous[100];  // some proper size here

VOID myfunc(LPCWSTR input){

  if( (wcslen(previous) != wcslen(input)) || (wcscmp(previous, input) != 0)){
    //they are different - do something
  }

  wcscpy(previous, input);
}

0
 

Author Comment

by:Koderz
ID: 22638658
Awesome! Thanks!
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

813 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now