SHARE
TWEET

Untitled

a guest Sep 11th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main()
  6. {
  7.     char **a=malloc(20*sizeof(char*));
  8.     char s[500];
  9.     for(int i=0;i<20;i++)
  10.     {
  11.         a[i]=malloc(21*sizeof(char));
  12.     }
  13.  
  14.     fgets(s,500,stdin);
  15.     char *tok=strtok(s," ");
  16.     int i=0;
  17.     while(tok != NULL && i<20)
  18.     {
  19.         strcpy(a[i],tok);
  20.    
  21.         i++;
  22.         tok=strtok(NULL," ");
  23.  
  24.     }
  25.     char temp[21];
  26.     strcpy(temp,a[0]);
  27.     strcpy(a[0],a[2]);
  28.     strcpy(a[2],temp);
  29.   int j=0;
  30.     while(a[j]!= i){
  31.  
  32.             printf("%s ",a[i]);
  33.           j++;
  34.  
  35.     }
  36.     return 0;
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top