STRING MANIPULATION FUNCTIONS
Presented By :
Manoj Kumar Guided By:
Panigrahi MR.Saroj Kumar
Regd Sahoo
No:240720100084
CONTENT
* Understanding string in
C
* Importance Of String
Manipulation
* Common String
Functions
-String Input/Output
-String Manipulation
Understanding
In C , AStrings In C of Characters Terminated by a
String is a sequence
Special null Character (\0).Strings In C are Essentially
Arrays Of Characters That Use The Null Terminator To
Indicate The
•Strings are End of The String
stored as arrays of characters.
•For example, the string “HELLO” is represented in memory as:
You can declare a string as
Importance Of String Manipulation
1. Text Processing
2. Data Formatting and Presentation
3. Search and Replace Operations
4. Communication Between Systems
6. Data Cleaning
Common String Functions
String Input/Output String Manipulation
Functions like printf(), gets(), and Functions like strlen(), strcpy(),
puts() for reading and writing strings. strcat(), and strcmp() for common
string operations.
a) String Length b) String Copy
Strlen(String) Strcpy(destination,Source)
Returns the length of the String Copies The Content of Source Into
(excluding the null terminator) Destination
c) String Concatenation d) String Comparison
Strcmp(str1,str2)
Strcat(Destination,Source)
Compares two strings lexicographically
Appends Source to the end of
returns 0 if equal
Destination
returns <0 if str1<str2
returns >0 if str1>str2
Example: Output:
#include <stdio.h> Length of str1: 5
#include <string.h> Length of str2: 5
After copying, str3: Hello
int main() {
char str1[50] = "Hello";
After concatenation, str1: Hello World
char str2[50] = "World";
char str3[50];
printf("Length of str1: %lu\n", strlen(str1));
printf("Length of str2: %lu\n", strlen(str2));
strcpy(str3, str1);
printf("After copying, str3: %s\n", str3);
Length of str1: 5
Length of str2: 5
After copying, str3: Hello
After concatenation, str1: Hello World
strcat(str1, " ");
strcat(str1, str2);
printf("After concatenation, str1: %s\n", str1);
return 0;
}
THANK YOU