Solved

Compare LPCWSTR's and store the most recent

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

758 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

23 Experts available now in Live!

Get 1:1 Help Now