Advertisement

Compiling a C Program

    On a personal computer using Visual Studio, you will create a .c file, e.g. hello.c (as in the previous example).  You will then compile it to produce a .exe file (e.g., hello.exe) and perhaps a .obj file (hello.obj).  Consult your compiler documentation (each one is different).



·        In Visual Studio, do a File|New and you will see the following dialog...



·        Here, you must first select Win32 Console Application.  Then press the ... button that appears to the right of the Location



·        Now choose the location.  You may need to create a folder on your file system.  In this case, I brought up the Windows NT explorer and created the new folder Ece11-s98.  Whatever you do, you should place the project in a place such that you can easily find it later.


·        Now that you have specified a Location, i.e. a folder where you want your project created, you should see the following...



·        Now, specify the name of your project.  Visual Studio will create a folder underneath the one you specified for Location by that name.  This will also become the name of your executable... Finally, click on the OK button to record your selection.




·        It is very important that you do each of these initial steps in the exact order that I have described above.  That is, first specify that you want a Console Application, then specify the location, then specify the project name.  Do not forget any of these steps.  In other words, pay attention!!!
 ·        As a result, you will see the following in Visual Studio

Notice that the Workspace window now has three tabs.  It has a ClassView tab, a FileView tab, and an InfoView tab.  Select (point the mouse to) the FileView tab. 



After selecting the FileView tab, you should see the following.  Notice what appears in the Workspace window...


·        Now we need to create a source file and include it in the project.  If we do the correct sequence of steps, Visual Studio will automatically include the new file into the project.
·        Do a File|New and select Text File and then specify a File name.  Do not accept the default choice, Active Server Page (or whatever happens to be the default).  Do not select C/C++ Header File.  Do not select C++ Source File.  Select Text File.  Do not forget to type in the file name, i.e. hello.c (or whatever you wish to call it), but it must end with .c !!!  The file suffix tells Visual Studio what type of file this is so it knows which compiler to invoke on it. Finally, click OK to select your choice.


As a result of your efforts, you should see the following.



·        I usually move the windows around at this point, adjusting the sizes.
·        Type in the program.



·        If you click on the + by Hello files under Workspace, you will see a list of all of the files in your project

·        Build your program by selecting the Build|Build menu option



·        Run it (Build | Execute)



Now let's look at the files:
Hello.dsw: this is your WORKSPACE
Hello.dsp: this is the project build file
These two files, along with hello.c are worth saving.



·        The program we just built is HELLO.EXE under the Debug directory


·        Because it is a CONSOLE application, we can run it directly from our Windows NT command (or Windows 95 Dos) prompt.
·        When I typed hello below at the Dos prompt, Windows ran the program hello.exe.  Below you can see the results of this run.


Compiling Under UNIX

To compile a C program under UNIX, one may do it in the following ways:

% cc hello.c

This compiles the file and creates an executable named a.out

% cc hello.c -o hello

This compiles the file but renames the executable hello

% cc -c hello.c

This compiles the file but does not link it, thus producing an object module which may be linked later on.  That file, by default, is hello.o

% cc hello.o -o hello

This links the object file hello.o to create the executable hello

Under UNIX, suffixes are important (i.e., .c versus .o).  They tell the compiler what type of file they are, i.e. a C program file versus an object module.

% cc foo.o bar.o -o fubar

This links two separately compiled modules into an executable named fubar.

The compiling process -- overview



Compiling process -- translation phases (ANSI)

1.  Physical source file characters are mapped to the source character set (including new-line characters and end-of-file indicators) if necessary.  Trigraph sequences are replaced by corresponding single-character internal representations.

2.  Each instance of a new-line character and an immediately preceding backslash character (\) is deleted, splicing physical source lines to form logical source lines.

3.  The source file is decomposed into preprocessing tokens and sequences of white-space characters (including comments).  A source file shall not end in a partial preprocessing token or comment.  Each comment is replaced by one space character.  New-line characters are retained.

4.  Preprocessing directives are executed and macro invocations are expanded.  A #include preprocessing directive causes the named header or source file to be processed from phase 1 through phase 4 recursively.

5.  Each source character set member and escape sequence in character constants and string literals is converted to a member of the execution character set.

6.  Adjacent character string literal tokens are concatenated and adjacent wide string literal tokens are concatenated.

7.  White-space characters separating tokens are no longer significant.  Each preprocessing token is converted into a token.  The resulting tokens are syntactically and semantically analyzed and translated.

8.  All external object and function references are resolved.  Library components are linked to satisfy external references to functions and objects not defined in the current translation.  All such translation output is collected into a program image which contains information needed for execution in its execution environment.



PDF FILE TO YOUR EMAIL IMMEDIATELY PURCHASE NOTES & PAPER SOLUTION. @ Rs. 50/- each (GST extra)

SUBJECTS

HINDI ENTIRE PAPER SOLUTION

MARATHI PAPER SOLUTION

SSC MATHS I PAPER SOLUTION

SSC MATHS II PAPER SOLUTION

SSC SCIENCE I PAPER SOLUTION

SSC SCIENCE II PAPER SOLUTION

SSC ENGLISH PAPER SOLUTION

SSC & HSC ENGLISH WRITING SKILL

HSC ACCOUNTS NOTES

HSC OCM NOTES

HSC ECONOMICS NOTES

HSC SECRETARIAL PRACTICE NOTES

2019 Board Paper Solution

HSC ENGLISH SET A 2019 21st February, 2019

HSC ENGLISH SET B 2019 21st February, 2019

HSC ENGLISH SET C 2019 21st February, 2019

HSC ENGLISH SET D 2019 21st February, 2019

SECRETARIAL PRACTICE (S.P) 2019 25th February, 2019

HSC XII PHYSICS 2019 25th February, 2019

CHEMISTRY XII HSC SOLUTION 27th, February, 2019

OCM PAPER SOLUTION 2019 27th, February, 2019

HSC MATHS PAPER SOLUTION COMMERCE, 2nd March, 2019

HSC MATHS PAPER SOLUTION SCIENCE 2nd, March, 2019

SSC ENGLISH STD 10 5TH MARCH, 2019.

HSC XII ACCOUNTS 2019 6th March, 2019

HSC XII BIOLOGY 2019 6TH March, 2019

HSC XII ECONOMICS 9Th March 2019

SSC Maths I March 2019 Solution 10th Standard11th, March, 2019

SSC MATHS II MARCH 2019 SOLUTION 10TH STD.13th March, 2019

SSC SCIENCE I MARCH 2019 SOLUTION 10TH STD. 15th March, 2019.

SSC SCIENCE II MARCH 2019 SOLUTION 10TH STD. 18th March, 2019.

SSC SOCIAL SCIENCE I MARCH 2019 SOLUTION20th March, 2019

SSC SOCIAL SCIENCE II MARCH 2019 SOLUTION, 22nd March, 2019

XII CBSE - BOARD - MARCH - 2019 ENGLISH - QP + SOLUTIONS, 2nd March, 2019

HSC Maharashtra Board Papers 2020

(Std 12th English Medium)

HSC ECONOMICS MARCH 2020

HSC OCM MARCH 2020

HSC ACCOUNTS MARCH 2020

HSC S.P. MARCH 2020

HSC ENGLISH MARCH 2020

HSC HINDI MARCH 2020

HSC MARATHI MARCH 2020

HSC MATHS MARCH 2020


SSC Maharashtra Board Papers 2020

(Std 10th English Medium)

English MARCH 2020

HindI MARCH 2020

Hindi (Composite) MARCH 2020

Marathi MARCH 2020

Mathematics (Paper 1) MARCH 2020

Mathematics (Paper 2) MARCH 2020

Sanskrit MARCH 2020

Sanskrit (Composite) MARCH 2020

Science (Paper 1) MARCH 2020

Science (Paper 2)

Geography Model Set 1 2020-2021


MUST REMEMBER THINGS on the day of Exam

Are you prepared? for English Grammar in Board Exam.

Paper Presentation In Board Exam

How to Score Good Marks in SSC Board Exams

Tips To Score More Than 90% Marks In 12th Board Exam

How to write English exams?

How to prepare for board exam when less time is left

How to memorise what you learn for board exam

No. 1 Simple Hack, you can try out, in preparing for Board Exam

How to Study for CBSE Class 10 Board Exams Subject Wise Tips?

JEE Main 2020 Registration Process – Exam Pattern & Important Dates


NEET UG 2020 Registration Process Exam Pattern & Important Dates

How can One Prepare for two Competitive Exams at the same time?

8 Proven Tips to Handle Anxiety before Exams!

BUY FROM PLAY STORE

DOWNLOAD OUR APP

HOW TO PURCHASE OUR NOTES?

S.P. Important Questions For Board Exam 2022

O.C.M. Important Questions for Board Exam. 2022

Economics Important Questions for Board Exam 2022

Chemistry Important Question Bank for board exam 2022

Physics – Section I- Important Question Bank for Maharashtra Board HSC Examination

Physics – Section II – Science- Important Question Bank for Maharashtra Board HSC 2022 Examination

Important-formula



THANKS