Is ctype.h an ANSI C header? I need to use 'tolower()'.
If it is not, which ANSI C function i could use instead of tolower?
Thank you!
tolower() and toupper() are located in the iostream header with Dev 4.9.7.4 / gcc 3.2.
Curtis
Thanks you, i decided to use ctype.h
Anyway i think it wont be necessary, i guess what i am trying to do is impossible:
char TempOcs[13]; if(strcmp((tolower(TempOcs)), "unnamed.ocs")==0) { ... }
I guess tolower/toupper expect a single character not a string right?
iostream with C? Isnt this only possible with C++?
opps, you are right. I use c++ :-P
tolower() and toupper() are ANSI C. The header is ctype.h. They convert single characters only. Converting the case of a string is simple enough:
char* str_to_lower( char* string ) { char* ptr = string ; while( *ptr != 0 ) { tolower( *ptr ) ; ptr++ ; }
return( string ) ; }
Returning string allows the function to be used as a parameter, like so:
if(strcmp((str_to_lower((TempOcs)), "unnamed.ocs")==0) { // etc. }
Log in to post a comment.
Is ctype.h an ANSI C header?
I need to use 'tolower()'.
If it is not, which ANSI C function i could use instead of tolower?
Thank you!
tolower() and toupper() are located in the iostream header with Dev 4.9.7.4 / gcc 3.2.
Curtis
Thanks you, i decided to use ctype.h
Anyway i think it wont be necessary, i guess what i am trying to do is impossible:
char TempOcs[13];
if(strcmp((tolower(TempOcs)), "unnamed.ocs")==0) {
...
}
I guess tolower/toupper expect a single character not a string right?
iostream with C? Isnt this only possible with C++?
opps, you are right. I use c++ :-P
Curtis
tolower() and toupper() are ANSI C. The header is ctype.h. They convert single characters only. Converting the case of a string is simple enough:
char* str_to_lower( char* string )
{
char* ptr = string ;
while( *ptr != 0 )
{
tolower( *ptr ) ;
ptr++ ;
}
return( string ) ;
}
Returning string allows the function to be used as a parameter, like so:
if(strcmp((str_to_lower((TempOcs)), "unnamed.ocs")==0)
{
// etc.
}