?
Solved

Compare LPCWSTR's and store the most recent

Posted on 2008-10-03
2
Medium Priority
?
983 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 1000 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

Independent Software Vendors: 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

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

770 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