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);
#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
కామెంట్లు
కామెంట్ను పోస్ట్ చేయండి
దయచేసి మీ సలహాలను సూచనలను స్పష్టంగా పేర్కొనగలరు. plz see that ur comments are 'acceptable' in a value based society.