string

function strstok

char* strtok(char *str, const char *delim);

Split string into tokens

The strtok() function parses a string into a sequence of tokens. On the first call to strtok() the string to be parsed should be specified in str. In each subsequent call that should parse the same string, str should be NULL.

The delim argument specifies a set of bytes that delimit the tokens in the parsed string. The caller may specify different strings in delim in successive calls that parse the same string.

Each call to strtok() returns a pointer to a null-terminated string containing the next token. This string does not include the delimiting byte. If no more tokens are found, strtok() returns NULL.

string

function strstok

Example

char str[] = "This is function strtok";
char delim[] = " ";
char* w = strtok(str, delim);
while(w != NULL){
	printf("%s\n", w);
	w = strtok(NULL, delim);
}
			
string

strcpy function

The C library function char *strcpy(char *dest, const char *src) copies the string pointed to, by src to dest.

Parameters

dest − This is the pointer to the destination array where the content is to be copied.

src − This is the string to be copied.

Return Value

This returns a pointer to the destination string dest.

string

strcat function

The C library function char *strcat(char *dest, const char *src) appends the string pointed to by src to the end of the string pointed to by dest.

Parameters

dest − This is pointer to the destination array, which should contain a C string, and should be large enough to contain the concatenated resulting string.

src − This is the string to be appended. This should not overlap the destination.

Return Value

This function returns a pointer to the resulting string dest.

string

strcat function

The C library function char *strcat(char *dest, const char *src) appends the string pointed to by src to the end of the string pointed to by dest.

Example
char dest[64] = "Hello";
char src[] = "data structure and algorithm";
strcat(dest, src);
printf("%s\n", dest);
			
string

itoa function

itoa function converts integer into null-terminated string. It can convert negative numbers too

char* itoa(int num, char* buffer, int base)

The third parameter base specify the conversion base. For example:- if base is 2, then it will convert the integer into its binary compatible string or if base is 16, then it will create hexadecimal converted string form of integer number

If base is 10 and value is negative, the resulting string is preceded with a minus sign (-). With any other base, value is always considered unsigned

itoa(1567, str, 10);//str: "1567"
itoa(-1567, str, 10);//str: "-1567"
itoa(1567, str, 2);//str: "11000011111"
itoa(1567, str, 16);str: "61f"