Copy string
Here we can copy the one variable value & we can assign to other variable.
Using strcpy() function .
Example
#include <stdio.h> int main(){ char name[20]="Vedanth"; char name1[20]; strcpy(name1,name); printf("Copyed after : %s",name1); return 0; }
Output
Copyed after : Vedanth
Compare two string
Here we can compare two string using the strcmp() function.
Example
#include <stdio.h> #include <string.h> main() { // declaration of char array char str1[20]="yuva"; char str2[20]="vyuva"; int value; // comparing both the strings using strcmp() function value=strcmp(str1,str2); if(value==0) { printf("Strings are same"); } else { printf("Strings are not same"); } }
Output
Strings are not same
String
׫ Previous Next »
Padma
Core Coure
Social
@2022, Padma Education.
We cannot warrant full correctness of all content, we try to give our best. While using Padma education website, you agree to have read and accepted our terms and Conditions , privacy policy.