Posts

Showing posts with the label String functions

String functions (strcat, strchr, strstr, strcmp,strlen,strupr,strlwr)

 Stringscan be manipulated in different ways. there is a set of predefined functions in C++, which are used to manipulated strings in different manners. the predefined functions which are declared in the string.h( or cstring header file in new C++ compilers) header file. Strings predefined functions are: strcat() strcat() function is used to concatenate two strings with each other. it appends the second string to the end of the other string. sytax: char *strcat(char *Destination const char *source); Program to use strcat() funstion: #include<iostream> using namespace std ; #include<cstring> int main () { char str1[10] = "HELLO" ; char str2[10] = "world" ; char str3[20] ; strcat(str1,str2) ; cout << "the string after concatenation is : " << str1 ; } output: the string after concatenation is : HELLOworld strchr() strchr() function is a function used to scan a string in forward direction and looking for the first occurren...