×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
compare two string - String
2D String Array Sort - String - String - C Language
1405    Arnab De    31/05/2019

2D Array sorting. This is a very easy program. Here we used strcmp() to compare the strings with in an array of string.

#include<string.h>
#include<stdio.h>
#include<conio.h>

int main()
{
	int i,j;
	char names[5][30],temp[30];
	printf("Enter 5 Names\n");
	for(i=0;i<5;i++)
	{
		gets(names[i]);
	}
	for(i=0;i<5;i++)
	{
		for(j=i+1;j<5;j++)
		{
			if(strcmp(names[i],names[j])>0)
			{
				strcpy(temp,names[i]);
				strcpy(names[i],names[j]);
				strcpy(names[j],temp);
				

			}
		}
	}
	printf("\n\n OUTPUTS  \n\n");
	for(i=0;i<5;i++)
	{
		puts(names[i]);
	}
}
compare two string - String
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Sri Sri Ramakrishna Paramahamsa
It is easy to talk on religion, but difficult to practice it.
Sri Sri Ramakrishna Paramahamsa
391
31.27
Today So Far
Total View (Lakh)
softetechnologies
01/01/2018     32997
28/06/2017     28646
02/08/2017     26134
26/05/2018     25238
15/05/2017     22311
06/07/2017     20920
01/08/2017     20537
21/04/2018     18172
25/06/2018     16255
14/07/2017     15657
softetechnologies