Solved

Compare LPCWSTR's and store the most recent

Posted on 2008-10-03
2
979 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
[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
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

732 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