[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Compare LPCWSTR's and store the most recent

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 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…
Suggested Courses

649 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