×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: C
Posted by: Damian Pytkowski
Added: Jun 2, 2016 11:46 AM
Modified: Jun 5, 2016 3:50 PM
Views: 31
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <windows.h>
  5. #include <string.h>
  6. #include <stdarg.h>
  7. #define ROZ 12
  8. char* join(int quant, ...);
  9. void main(int argc,char *argv[])
  10. {
  11.     char *tab;
  12.     tab=join(3,"01111111111111111112Ala","011111111111111111112ma","01111111111112kota");
  13.     printf("%s",tab);
  14.     free(tab);
  15. }
  16. char* join(int quant, ...)
  17. {
  18.    char *p,*bufor, *out;
  19.    int i=1,j=0,k=0;
  20.    va_list arg;
  21.    va_start(arg,quant);
  22.    p=(char*)calloc(1,20);
  23.    out=(char*)calloc(1,20);
  24.    while(i++<=quant){
  25.         p = va_arg(arg,char*);
  26.         bufor = p;
  27.         while(bufor[j]!=0){out[k++]=bufor[j];j++;}
  28.         out=(char*)realloc(out,(sizeof(out)+sizeof(bufor)+2));//*2?
  29.         j=0;
  30.         }
  31.    va_end(arg);
  32.    free(p);
  33.    return out;
  34. }
  35.