ch7-system

Chapter_7     Exercise_7-8 frand     Exercise_7-9







system.c     K&R, p. 167         download


#include <stdio.h> // for printf()
#include <stdlib.h> // for system()

int main(int argc, char*argv[])
{
if (argc != 2)
{
printf("Usage: ./system command\n");
return 1; // end program, signalling error
}

system(argv[1]);

return 0;
}
/*
gcc system.c -o system
./system
Usage: ./system command

./system date
Sun 03 Sep 2023 11:06:19 AM EEST

./system dir
isupper isupper.c system system.c

./system ls -a
Usage: ./system command

./system "ls -a"
. .. isupper isupper.c system system.c

./system uname
Linux

./system whoami
user

./system w

./system "ls -l"

./system "cat system.c"
*/









Chapter_7     Exercise_7-8 BACK_TO_TOP frand     Exercise_7-9



Comments

Popular posts from this blog

Contents

Blogger Page Margins in Contempo