Advertisement
Guest User

Untitled

a guest
May 25th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5. #include <limits.h>
  6.  
  7.  
  8.  
  9. int main(int argc, char *argv[])
  10. {
  11.  
  12. char *string;
  13. string = malloc(sizeof(char) * PATH_MAX * argc);
  14. size_t len = 0;
  15.  
  16. while ( *++argv )
  17. {
  18. while ( *(*argv) != '\0' )
  19. {
  20. string[len] = *(*argv);
  21. ++len;
  22. *(*argv)++;
  23.  
  24. }
  25. if ( *(argv + 1))
  26. {
  27. string[len ] = ' ';
  28. ++len;
  29. }
  30.  
  31. }
  32. string[len++] = '\n';
  33.  
  34. write(STDOUT_FILENO, string , sizeof(char) * len);
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement