954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Identify series of a string

If your input is "abc". What would be the logic to accept the strings, bca,acb,bac,cab,cba,abc (ie. the same string with chars placed in any order)
and reject all other input strings like aab, cdb, xyz etc ?
Note: The reference string("abc") is not fixed, logic should work for any constant string irrespective of its size.

swets_here
Newbie Poster
4 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

the string class has a function, find_first_not_of( ), where you can just give it your original string "abc". It searches to find any characters that aren't in the list of the ones you provided. (you would want it to return -1 which means it didn't find any)

winbatch
Posting Pro in Training
466 posts since Feb 2005
Reputation Points: 68
Solved Threads: 18
 

Thanks! I tried using it but the compiler fails to recognize this function. Is it present in the stdlib?

Is the usage like,
check_flag = find_first_not_of(abc) ;
//where to I give the string to be compared?

Can you pls gimme the exact protype for this function find_first_not_of( )?

swets_here
Newbie Poster
4 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 
winbatch
Posting Pro in Training
466 posts since Feb 2005
Reputation Points: 68
Solved Threads: 18
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You