Showing posts with label C Program. Show all posts
Showing posts with label C Program. Show all posts

Thursday, August 16, 2007

Execute shell commands from a C program

Heres a C Program that use system() function to
execute shell commands:

See man system for more information:

[root@linuxbox C_Programs]# cat test.c
#include
main()
{
printf ("Files More than 10 MB !!\n");
system("find . -size +10000k");
return 0;
}

[root@linuxbox C_Programs]# gcc test.c

[root@linuxbox C_Programs]# ./a.out
Files More than 10 MB !!
./xemacs-packages-extra-20061221-1.fc7.noarch.rpm

Wednesday, August 15, 2007

Programming C under Unix

Writing a test Program in C (Unix):
====================================
[root@linuxbox C_Programs]# cat test.c
#include
main()
{

printf ("Hello Sriram!!\n");

return 0;

}

Executing the above :
=====================
[root@linuxbox C_Programs]# gcc test.c

[root@linuxbox C_Programs]# ls
a.out test.c

[root@linuxbox C_Programs]# ./a.out
Hello Sriram!!