Advertisement
Guest User

Untitled

a guest
May 28th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdarg.h>
  4. #include <string.h>
  5.  
  6. int scal(int ile, ...){
  7. va_list napisy;
  8. int d=0;
  9. int i=0;
  10.  
  11. va_start (napisy, ile);
  12. for(i=0 ; i<ile ; i++)
  13. d += strlen(va_arg(napisy, char*));
  14. va_end(napisy);
  15.  
  16. int nl=0;
  17. char *nap = calloc(sizeof(char), d);
  18. va_start (napisy, ile);
  19. for(i=0; i<ile; i++){
  20. char *s = va_arg(napisy, char*);
  21. printf("%s ", s);
  22. strcpy(nap+nl, s);
  23. nl += strlen(s);
  24. }
  25. printf("\n%s\n\n", nap);
  26. free(nap);
  27. return 0;
  28. }
  29.  
  30. int main()
  31. {
  32. printf("Dla mojej kochanej Ani :*\n\n");
  33. scal(3, "Ania", "Robert", "Pakowscy");
  34. scal(2, "Kocham", "Cie");
  35. scal(6, "K", "O", "C", "H", "A", "M");
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement