Blog / Uncategorized March 18, 2015

Hello World 2 Programming

Hello World 2 Programming, using UNIX/Linux

1- type into the shell

[cpp]
vi chapter1_2.c
[/cpp]

copy the text below

[cpp]
#include<stdio.h>

int main(int argc, char*argv[])

{

int i=0;

printf("hello, you are learning C!!\n");

printf("Number of arguments to the main function:%d\n, argc");

for(i=0; i&lt;argc; i++)

{

printf("argument number %d is %s\n",i, argv[i]);

}

return 0;

}
[/cpp]

press ESC one time, then :wq

2- type

[cpp]
gcc -o hello2 chapter1_2.c
[/cpp]

3- run the c program

[cpp]
./ hello2
[/cpp]
4- now try type
[cpp]
./hello2 my name is ahmed
[/cpp]

You may also like...