Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

CLASS XI Standard Header Files and Their Functions String Functions in Header file <string.

h>

strcmp - Strcmp compares two strings and returns an integer indicating the difference between the strings. If the strings match, then the number returned is 0. and ( <0 or >0 when 2 strings are
unequal)

strcat - combines two strings. strcpy - copies one string to another. The destination must be large enough to accept the contents of the source string. strlen - returns the length of a string. strstr - returns a pointer to the first instance of a particular string inside a string. strlwr: Converts all characters to lower case. Strupr: Converts all characters to upper case. Strrev: Reverses the string.
Character functions in header file <ctype.h> isalpha(c)-check whether the character argument is alphabetic or not. islower(c)- check whether the character argument is lowercase or not. isupper(c) - check whether the character argument is uppercase or not. isdigit(c)- check whether the character argument is digit or not. isalnum(c)- check whether the character argument is alphanumeric or not. tolower()-converts argument in lowercase if its argument is a letter. toupper(c)- converts argument in uppercase if its character argument is a letter. Mathematics functions in header file <math.h> pow(x,y)-returns x raised to power y. sqrt(x)-returns square root of x. Random functions in header file <stdlib.h> random(num)-returns a random number between 0 and (num-1) randomize()-initializes the random number generator with a random value. Character I/O Function: get()-input single character from standard input device. put()-output single character from standard output device getch()-read from keyboard putch()-write to screen. getchar()-return single character from a standard input device. putchar()-transmit single character to standard output device. gets()-used to read a string of character from the standard input file(stdin). puts()-used to copy a null-terminated string to standard output file (stdout). To find Substring in a given string char ms[80],ss[80]; gets(ms); gets(ss); int k,l; for(int i=0;i<strlen(ms);i++) {if(ms[i]==ss[0]) for(k=i+1,l=1;l<strlen(ss);k++,l++) if(ms[k]!=ss[l]) break; if(l==strlen(ss)) {cout<<"found"; break; } } if(i==strlen(ms)) cout<<"not found";

You might also like