tags:

views:

29

answers:

2

I am not trying to set the local hostname. In my app using a edit control need to accept a host name (fully qualified with DNS / without).

We do know we cannot use chars a (\ / ! @ # $ % ^). Is there a better way than programmatically parsing the user input.

Code needs to work in all languages (multi byte char set)

Thanks AnilG

A: 

Not that I could think of. The effort to do this yourself is pretty slim, though. See _mbschr and _mbscspn for good examples on how to search for a single character and multiple characters.

There is also a good overview over string functions supported by Visual Studio here.

char string[] = "xyzabc";
int pos;

pos = strcspn( string, "abc" );
printf( "First a, b or c in %s is at character %d\n", string, pos );
A: 

You can use the PCRE library to match the string against a regular expression.

Kristopher Johnson