Thursday, June 4, 2015

string(10)

#include <stdio.h>
#include <string.h>
///string (function)

///int main()
///{
///char str[100]="koushik";
///strlen(str);
///printf("%d\n",strlen(str));
///return 0;
///}


///int main()
///{
///char str1[100]="koushik";
///char str2[100]="Ahamed";
///strcpy(str1,str2);
///printf("%s\n",str1);
///return 0;
///}


///int main()
///{
///char str1[100]="koushik";
///char str2[100]="Ahamed";
///strncpy(str1,str2,3);
///str1[3]='\0';
///printf("%s\n",str1);
///return 0;
///}

///int main()
///{
///char str1[100]="koushik";
///char str2[100]="Ahamed";
///strcat(str1," ");
///strcat(str1,str2);
///printf("%s\n",str1);
///return 0;
///}

///int main()
///{
///char str1[100]="koushik";
///char str2[100]="Ahamedkushal";
///strncat(str1,str2,6);
///printf("%s\n",str1);
///return 0;
///}


///int main()
///{
///char str1[100]="BCD";
///char str2[100]="AYZ";
///strcmp(str1,str2);
///printf("%d",strcmp(str1,str2));
///return 0;
///}


///int main()
///{
///char str1[100]="BCD";
///char str2[100]="XYZ";
///strcmp(str1,str2);
///printf("%d",strcmp(str1,str2));
///return 0;
///}


///int main()
///{
///char str1[100]="BCD";
///char str2[100]="BCD";
///strcmp(str1,str2);
///printf("%d",strcmp(str1,str2));
///return 0;
///}


///int main()
///{
///char str1[100]="BCD";
///char str2[100]="BCD";
///if(strcmp(str1,str2)==0);
///printf("They are same\n");
///return 0;
///}


///int main()
///{
///char str1[100]="BCD";
///char str2[100]="BCD";
///if(!strcmp(str1,str2));
///printf("They are same\n");
///return 0;
///}


///int main()
///{
///char str1[100]="BBD";
///char str2[100]="BDB";
///strncmp(str1,str2,2);
///printf("%d",strncmp(str1,str2,2));
///return 0;
///}


///int main()
///{
///char str1[100]="BBD";
///char str2[100]="BBB";
///if(!strncmp(str1,str2,2));
///printf("They are same\n");
///return 0;
///}


int main()
{
char str1[100]="BBB";
char str2[100]="BBB";
printf("%d",strcoll(str1,str2));
return 0;
}

///***strcmp and strcoll closely same ***///


No comments:

Post a Comment