Results 1 to 3 of 3
Hi friends,
Is there any inbuilt function other than strncmp which can evaluate a string as given below,
array[10]={""}; --> has no values
array[10]={" "}; --> contains 12 spaces
array[10]={"1234567890"}; ...
- 08-19-2010 #1Just Joined!
- Join Date
- Oct 2008
- Posts
- 30
Function to validate a string with space
Hi friends,
Is there any inbuilt function other than strncmp which can evaluate a string as given below,
array[10]={""}; --> has no values
array[10]={" "}; --> contains 12 spaces
array[10]={"1234567890"}; --> contains 12 char values
array[10]={"a3cvvae3"}; --> contains alp-num values
my requirement is " if all 10 values are spaces print 1 else if it contains some values print 2 else print 3.
if i use strlen, even space is counted !
I know that i can evaluate using for loop by checking 1 by 1 char, and using strcmp function, is there any other way ??
Thanks
Jayasekar
- 08-20-2010 #2Just Joined!
- Join Date
- Jul 2010
- Posts
- 53
Code:i = memcmp(array," ",10)==0 ? 2 : array[0]=='\0' ? 3 : 1 ;
- 08-21-2010 #3Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Please don't post class problems here! Your initializers are really bogus and you need to learn why...
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote