Strings (theory)

 String is a kind of datatype in variable but it store text, it is a kind of array in which the last index is null value, strings are declare into double quotes.

gets() and puts() two functions declare in stdio.h header file, these functions are used as I/O operations to insert and print data from the string, puts function is used to pirnt the data inserted by gets function

Note: puts function will not work without gets function().

fgets() this function is used to insert the limited text into the string

Syntax: fgets (string name ,size,stdin);


Functions that works with the strings

note: these function need #include<string.h> header file

1. strlen() to find the length of string. it works in printf

2. strcpy(destination string, main string) : copy

3. strcat(a,b) : combine :works in printf

4.strcmp(a,b) : compare two strings : used with if statement

5. strrev(a) : reverse a string

6.strlwr(b) : convert to lowercase

7.strupr() : convert to uppercase

8.strstr()

No comments:

Post a Comment