Advertisement
banovski

“system” function

Jan 21st, 2022 (edited)
1,361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. /* Write a program named ALPHA that asks for the user’s name. Then
  2. have ALPHA call a program named BETA that displays the user’s name. */
  3.  
  4. /* Both programs are listed here: don't compile. Also make sure you
  5. provide the right path to beta and specify the right number of elements
  6. in the app array. */
  7.  
  8. /* alpha.c source code */
  9.  
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <stdlib.h>
  13.  
  14. int main()
  15. {
  16.      char name[16];
  17.      char app[29] = "~/Test/beta ";
  18.      puts("Enter your name (not more than 14 characters): ");
  19.      fgets(name, 15, stdin);
  20.      system(strcat(app, name));
  21.      return(0);
  22. }
  23.  
  24. /* beta.c source code */
  25.  
  26. #include <stdio.h>
  27.  
  28. int main(int argc, char *argv[])
  29. {
  30.      printf("Your name is %s\n", argv[1]);
  31.      return(0);
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement