char * strtrim(char* s ) to remove any space character(such as '\t' , ' ' ...) in a string
2011-08-05 21:41
651 查看
here is the function
char * strtrim(char* s )
it's designed to remove any space character(such as '\t' , ' ' ...) in a string
char * strtrim(char* s )
it's designed to remove any space character(such as '\t' , ' ' ...) in a string
char* strtrim(char* s) { int len=0,i=0,j=0,k=0; len = strlen(s); if( len == 0 ) return NULL; j = len -1; while(s[j] == ' ' || s[i] == '\t' ) { s[j--] = '\0'; if(j < 0 ) break; } while( s[i] == ' ' || s[i] == '\t' ) i++; if( i == 0 ) return s; while( s[k] != '\0') s[k++] = s[i++]; return s; }
相关文章推荐
- In Powershell Cast Unicode character to char - 'WHITE SMILING FACE' (U+263A)
- How to get rid of `deprecated conversion from string constant to 'char*'` warnings in GCC?
- warning:deprecated conversion from string constant to 'char *'解决方案
- warning:deprecated conversion from string constant to 'char *'
- watir 学习问题in `require': no such file to load -- watir (LoadError)
- c++:warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
- error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)
- warning:deprecated conversion from string constant to 'char *'解决方案
- warning:deprecated conversion from string constant to 'char *'解决方案
- warning:deprecated conversion from string constant to 'char *'
- The transaction log for database 'NJ_Address' is full. To find out why space in the log cannot be
- warning:deprecated conversion from string constant to 'char *'解决方案
- warning:deprecated conversion from string constant to 'char *'解决方案
- 【求助】 no matching function for call to `strcpy(std::string&, char*&)'
- warning: deprecated conversion from string constant to 'char*'
- undo表空间不足,ORA-30036: unable to extend segment by 8 in undo tablespace 'UNDOTBS2'
- error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)
- Conversion from string literal to 'char *' is deprecated 问题原因
- warning:deprecated conversion from string constant to 'char *'解决方案
- watir 学习问题in `require': no such file to load -- watir (LoadError)