View Code of Problem 78

#include<stdio.h>
#include<string.h>
int main()
{
  char str1[100],str2[100],str[100],temp[100];
  gets(str1);
  gets(str2);
  gets(str3);
  if(strcmp(str1,str2)<0)
  {
    strcpy(temp,str1);
    strcpy(str1,str2);
    strcpy(str2,temp);
  }
  if(strcmp(str1,str3)<0)
  {
    strcpy(temp,str1);
    strcpy(str1,str3);
    strcpy(str3,temp);
  }
  if(strcmp(str3,str2)>0)
  {
    strcpy(temp,str2);
    strcpy(str2,str3);
    strcpy(str3,temp);
  }
  puts(str1);
  puts(str2);
  puts(str3);
}

/*
Main.c: In function 'main':
Main.c:6:3: warning: 'gets' is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
   gets(str1);
   ^
Main.c:7:3: warning: 'gets' is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
   gets(str2);
   ^
Main.c:8:3: warning: 'gets' is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
   gets(str3);
   ^
Main.c:8:8: error: 'str3' undeclared (first use in this function)
   gets(str3);
        ^
Main.c:8:8: note: each undeclared identifier is reported only once for each function it appears in
Main.c:5:28: warning: unused variable 'str' [-Wunused-variable]
   char str1[100],str2[100],str[100],temp[100];
                            ^
*/

Double click to view unformatted code.


Back to problem 78