Click here to Skip to main content
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 Sam700

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)

  Print Answers RSS
0 DamithSL 320
1 Sergey Alexandrovich Kryukov 222
2 OriginalGriff 155
3 Peter Leow 115
4 Afzaal Ahmad Zeeshan 114
0 OriginalGriff 7,510
1 DamithSL 5,519
2 Sergey Alexandrovich Kryukov 5,044
3 Maciej Los 4,961
4 Kornfeld Eliyahu Peter 4,514

Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2014
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