Click here to Skip to main content
11,432,119 members (57,967 online)
Rate this: bad
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 Sam710

1 solution

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

Solution 1

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

Soren Madsen
Mr Sam at 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 *'?
PJ Arends at 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.
Maximilien at 25-Feb-13 13:23pm
can you show the code you are using ?

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

Advertise | Privacy | Mobile
Web02 | 2.8.150428.2 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2015
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