some additional clever string functions More...
#include "string_addon.h"
Functions | |
void | l_trim (char *string, char sign) |
eleminates all leading signs which are equal to the given one | |
void | r_trim (char *string, char sign) |
eleminates all signs at the end of a string which are equal to the given one | |
void | trim (char *string, char sign) |
eleminates all signs of the given type at the end or at the beginning of a string | |
char * | strtrok_single_char (char *c_ptr_search, char c_search) |
searches for the first occurence of a single character in a string and creates a string with the content till this point. |
some additional clever string functions
Target/Compiler: AVR_MEGA / GCC(WinAVR)
\
void l_trim | ( | char * | string, | |
char | sign | |||
) |
eleminates all leading signs which are equal to the given one
*string | - string to investigate | |
sign | - character which shall be eliminated |
This function eliminates all leading characters in a string. The character which shall be eliminated and the string to be checked have to be addressed in the call. ------------ Testcode sprintf(str_rcv_usart,""); l_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart,"a"); l_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart," test x"); l_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart," test mit blanks "); l_trim(str_rcv_usart,_ASCII_SPACE);
void r_trim | ( | char * | string, | |
char | sign | |||
) |
eleminates all signs at the end of a string which are equal to the given one
*string | - string to investigate | |
sign | - character which shall be eliminated |
This function eliminates all characters at the end of a string. The character which shall be eliminated and the string to be checked have to be addressed in the call. ------------ Testcode sprintf(str_rcv_usart,""); r_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart,"a"); r_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart," test x "); r_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart," test mit blanks "); r_trim(str_rcv_usart,_ASCII_SPACE);
char* strtrok_single_char | ( | char * | c_ptr_search, | |
char | c_search | |||
) |
searches for the first occurence of a single character in a string and creates a string with the content till this point.
*c_ptr_search | - string used for search | |
c_search | - character which shall be searched |
searches for the first occurence of a single character in a string and replaces it with '/0'. It returns a pointer to the beginning of the "new" string if it found the character. The function remembers the last position where a character has been found. Calling the function with a c_ptr_search=NULL continuous the search at the stored location.
void trim | ( | char * | string, | |
char | sign | |||
) |
eleminates all signs of the given type at the end or at the beginning of a string
*string | - string to investigate | |
sign | - character which shall be eliminated |
This function eliminates all characters at the end and at the beginning of a string. The character which shall be eliminated and the string to be checked have to be addressed in the call. ------- Testcode sprintf(str_rcv_usart," op1"); trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart,"a"); trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart," help aber woher%c ",toascii(13)); trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart,""); trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart,"help %c",toascii(13)); trim(str_rcv_usart,_ASCII_SPACE);