100% SET 1 & 4: 6(b) string handling functions

#include <stdio.h>
#include<string.h>
void main()
{
    char str1[ ]="satyamu", str2[ ]="cheppu";
    int length;

   printf("\n Before copying str1=%s, str2=%s",str1,str2);
   strcpy(str1,str2);
    printf("\n After copying str1=%s, str2=%s",str1,str2);
   
    printf("\n concatenating the two string satyamu_ and paluku is %s", strcat(str1,str2));
   
    printf("\n if strings are same then strcmp gives %d",strcmp("Chennai","Chennai"));
   
    printf("\n if strings are not same then strcmp gave %d",strcmp("Chennai","ChinToo"));

    printf("\n if strings are not same then strcmp gave %d",strcmp("ChinToo","Chennai"));
   
    length=strlen(str1);

    printf("\n length of string cheppucheppu= %d",length);




   
}

తెరమీద

Before copying str1=satyamu, str2=cheppu
 After copying str1=cheppu, str2=cheppu
 concatenating the two string satyamu_ and paluku is cheppucheppu
 if strings are same then strcmp gives 0
 if strings are not same then strcmp gave -1
 if strings are not same then strcmp gave 1
 length of string = 12

కామెంట్‌లు

ఈ బ్లాగ్ నుండి ప్రసిద్ధ పోస్ట్‌లు

100% C prog to write content into a file and then read it back onto the console

Spic macay

శ్రీరస్తు.. రామలింగ 18-1-24 (సూరసాని వారి ఆహ్వానము)