×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: C
Posted by: Damian Pytkowski
Added: May 19, 2016 11:49 AM
Modified: May 21, 2016 10:16 AM
Views: 30
do domu 2
Copy a.txt b.txt
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <windows.h>
  5. #include <string.h>
  6. #define ROZ 12
  7. char* join(int argc,char *argv[]);
  8. void main(int argc,char *argv[])
  9. {
  10.    char *destination;
  11.    int i;
  12.    destination=join(argc,argv);
  13.    printf("%s",destination);
  14.    free(destination);
  15.  
  16. }
  17. char* join(int argc,char *argv[])
  18. {
  19.    char *p;
  20.    int i=1,j=0,t=-1;
  21.    p=(char*)calloc(1,1);
  22.    while(i<argc){
  23.         while(argv[i][j]!=0){
  24.             p[++t]=argv[i][j++];
  25.             p=(char*)realloc(p,sizeof(char)*(t+3));
  26.         }
  27.         i++;j=0;
  28.         p[++t]=' ';
  29.    }
  30.    p[t]=0;
  31.    return p;
  32. }
  33.