View Code of Problem 22

#include <stdio.h>

void main(){
	
	char a[100],b[100],same[100],temp;
	int i,j,len1,len2,k;
	while(gets(a) != NULL)
	{
		gets(b);
		k=0;
		len1 = strlen(a);
		len2 = strlen(b);
		for(i=0; i < len1; i++ )
		{
			for(j=0; j < len2; j++)
			{
				if(a[i] == b[j])
				{
					same[k++] = b[j];
					breeak;
				}
				same[k] = '\0';
			}
		}
		for(i=0; i < k; i++)
		{
			for(j=0; j < k; j++)
			{
				if(same[i] > same[j])
				{
					temp = same[i];
					same[i] = same[j];
					same[j] = temp;
				}
			}
		}
		for(i=0; i < k; i++)
			printf("%c",same[i]);
		printf("\n");
	}
}
/*
Main.c:3:6: warning: return type of 'main' is not 'int' [-Wmain]
 void main(){
      ^
Main.c: In function 'main':
Main.c:7:2: warning: 'gets' is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
  while(gets(a) != NULL)
  ^
Main.c:9:3: warning: 'gets' is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
   gets(b);
   ^
Main.c:11:3: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
   len1 = strlen(a);
   ^
Main.c:11:10: warning: incompatible implicit declaration of built-in function 'strlen'
   len1 = strlen(a);
          ^
Main.c:20:6: error: 'breeak' undeclared (first use in this function)
      breeak;
      ^
Main.c:20:6: note: each undeclared identifier is reported only once for each function it appears in
*/

Double click to view unformatted code.


Back to problem 22