Click here to Skip to main content
12,752,040 members (29,098 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++ C MFC

please suggest below problem.

CString str1 = "/\?<>|:*"; //contains only these letters
CString str2 = "CodeProject@25_Feb#2013!"; // contains no's special chars, letters

need to compare both str1 and str2. str2 should not match with any character in str1.

Thanks and Regards
Posted 25-Feb-13 6:22am
Mr Sam725

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

strspn[^] is your friend.
SoMad 25-Feb-13 11:59am
Or CString::FindOneOf()[^]. The name is just a little more intuitive :).

Soren Madsen
Mr Sam 25-Feb-13 12:32pm
I did not get success by using above functions. Any other solutions please. And how to resolved this : cannot convert parameter 1 from 'CString' to 'const char *'?
Maximilien 25-Feb-13 13:23pm
can you show the code you are using ?
PJ Arends 26-Feb-13 11:12am

unicode / non-unicode conflict. use the the neutral _tcsspn version or the unicode wcsspn version. Or better yet, use the function suggested by SoMad.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100