Your first linux programs

11
Your First Linux Program BY AHMED AL ZAIDY

Transcript of Your first linux programs

Page 1: Your first linux programs

Your First Linux

ProgramBY AHMED AL ZAIDY

Page 2: Your first linux programs

Made Specially for Jones College

Students

INTRODUCTION TO UNIX

2015

Page 3: Your first linux programs

PuTTY

You need to Download the PuTTYShell Program.

After Starting PuTTY Enter the Linux Server Information

Server Address: DLLinux.jones.edu

After That click on Open.

Enter your Username and Password

* Note you will NOT see the password typed into the Shell but complete the password and press Return (Enter).

Page 4: Your first linux programs

Hello Word Program Source Code

First C Programming

Vi Editor

Type into the shell

vi hello.c

Copy the source code below.

#include<stdio.h>

void main()

{

printf("Hello! This is my first C

program with Ubuntu

11.10\n");

/* Do something more if you

want */

}

Page 5: Your first linux programs

Hello Word Program Source Code

First C Programming

Vi Editor

Press ESC Button

Type into vi

:wq

To write the file and quite

type into the shell the code

gcc hello.c -o hello1

Then type

./hello1

Page 6: Your first linux programs

Hello Word 2 Program Source Code

Second C Programming

VI Editor

Type into Shell

vi chapter1_2.c

Copy the text into the vi

Then press ESC

Type :wq

Then type into the shell

gcc -o hello2 chapter1_2.c

./hello2

./hello2 my name is ahmed

#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;

}

Page 7: Your first linux programs

A to Z Program Source Code

Third C Programming

VI Editor

Type into Shell

vi atoz.c

Copy the text into the vi

Then press ESC

Type :wq

Then type into the shell

gcc -o atoz1 atoz.c

./atoz1

#include <stdio.h>

int main()

{

char c;

for(c='A'; c<='Z'; ++c)

printf("%c ",c);

return 0;

}

Page 8: Your first linux programs

Screen Shot First C Program

Page 9: Your first linux programs

Screen Shot Second C Program

Page 10: Your first linux programs

Screen Shot Third C Program