Advertisement
Aminpro

[ECP 1016]Tutorial 9 Question 8

Aug 26th, 2012
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. //https://www.facebook.com/AminproPastebin
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6.     void swapf(char *ss1, char *ss2);
  7.  
  8. int main(void)
  9. {
  10.  
  11.     char s1[50], s2[50];
  12.     printf("Enter string 1: ");
  13.     fgets(s1, 50, stdin);
  14.     printf("Enter string 2: ");
  15.     fgets(s2, 50, stdin);
  16.  
  17.     printf("The ordered words are : \n");
  18.     puts(s1);
  19.     puts(s2);
  20.     swapf(s1, s2);
  21.  
  22.  
  23.  
  24.  
  25.     return (0);
  26. }
  27.  
  28.  
  29. void swapf(char *ss1, char *ss2){
  30.     char temp[50];
  31.     if (strcmp(ss1, ss2)> 0){
  32.    
  33.     strcpy(temp, ss1);
  34.     strcpy(ss1, ss2);
  35.     strcpy(ss2, temp);
  36.  
  37. }
  38.  
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement