Skip to main content

Running C Programs

Objectives:

Having read this section you should be able to:

1.Edit, link and run your C programs



This section is primarily aimed at the beginner who as no or little experience of using compiled languages. We cover the various stages of program development. The basic principles of this
section will apply to what ever C compiler you choose to use, the stages are nearly always the same


The Edit-Compile-Link-Execute Process:

Developing a program in a compiled language such as C requires at least four steps:

1.editing (or writing) the program
2.compiling it
3.linking it
4.executing it

We will now cover each step separately.


Editing:

You write a computer program with words and symbols that are understandable to human beings. This is the edit part of the development cycle. You type the program directly into a
window on the screen and save the resulting text as a separate file. This is often referred to as the source file (you can read it with the TYPE command in DOS or the cat command in unix).

The custom is that the text of a C program is stored in a f ile with the extension .c for C programming language


Compiling:

You cannot directly execute the source file. To run on any computer system, the source file must be translated into binary numbers understandable to the computer's Central Procesing Unit
(for example, the 80*87 microprocessor). This process produces an intermediate object file - with the extension .obj, the .obj stands for Object.



Linking:

The first question that comes to most peoples minds is Why is linking necessary? The main reason is that many compiled languages come with library rountines which can be added to your
program. Theses routines are written by the manufacturer of the compiler to perform a variety of tasks, from input/output to complicated mathematical functions. In the case of C the standard
input and output functions are contained in a library (stdio.h) so even the most basic program will require a lib rary function. After linking the file extension is .exe which are executable

files.


Executable files:

Thus the text editor produces .c source files, which go to the compiler, which produces .obj object files, which go to the linker, which produces .exe executable file. You can then run
.exe files as you can other applications, simply by typing their names at the DOS prompt or run using windows menu.


Using Microsoft C:

Edit stage:
Type program in using one of the Microsoft Windows editing packages.

Compile and link:
Select Building from Make menu. Building option allows you to both compile and link in the same option.

Execute:
Use the Run menu and select Go option.

Errors:
First error highlighted. Use Next Error from Search menu for further errors if applicable.

If you get an error message, or you find that the program doesn't work when you finally run it (at least not in the way you anticipated) you will have to go back to the source file - the .c file -
to make changes and go through the whole development process again!


Unix systems:

The University's central irix Service is a Silicon Graphics Inc. Challenge XL system which runs a Unix-like operating sysem called IRIX. The basic information to run a C program on this

system is covered in document HT.SI.05 - How To... Run C Programs On The irix Service. Although this document refers to the IRIX operating system many of the command options will
be common to all Unix systems.

On all Unix systems further help on the C compiler can be obtained from the on-line manual. Type

man cc

on your local Unix system for more information.

Please note that Unix is a case sensitive operating system and files named firstprog.c and FIRSTPROG.c are treated as two separate files on these system. By default the Unix system

compiles and links a program in one step, as follows:

cc firstprog.c

This command creates an executable file called a.out that overwrites any existing file called a.out. Executable files on Unix are run by typing their name. In this case the program is run as
follows:

a.out

To change the name of the executable file type:

cc -o firstprog.c

This produces an executable file called firstprog which is run as follows:

firstprog

Comments

Popular posts from this blog

download Code blocks 13.12 mingw.setup .exe 97 mb

NOTE: A newer version is been updated on the site ... visit here  http://vastgk.blogspot.com/2017/07/download-code-blocks-1601-mingwsetup.html File Date Download from codeblocks-13.12-setup.exe 27 Dec 2013 BerliOS  or  Sourceforge.net codeblocks-13.12mingw-setup.exe 27 Dec 2013 BerliOS  or  Sourceforge.net codeblocks-13.12mingw-setup-TDM-GCC-481.exe 27 Dec 2013 BerliOS  or  Sourceforge.net NOTE : The codeblocks-13.12mingw-setup.exe file  includes  the GCC compiler and GDB debugger from  TDM-GCC  (version 4.7.1, 32 bit). The codeblocks-13.12mingw-setup-TDM-GCC-481.exe file includes the TDM-GCC compiler, version 4.8.1, 32 bit. While v4.7.1 is rock-solid (we use it to compile C::B), v4.8.1 is provided for convenience, there are some known bugs with this version related to the compilation of Code::Blocks itself. IF UNSURE, USE "codeblocks-13.12mingw-setup.exe"!  \ Linux 32-bit: Dis...

DOWNLOAD CODE BLOCKS 16.01 MINGW.SETUP .EXE 86.3 MB

Code::Blocks for Mac is a free C, C++ and Fortran IDE that has a custom build system and optional Make support. The application has been designed to be very extensible and fully configurable. Code::Blocks is an IDE packed full of all the features you will need. It has a consistent look, feel and operation across its supported platforms. It has been built around a plugin framework, therefore Code::Blocks can be extended with plugins. Support for any kind of functionality can be added by installing/coding a plugin. Key features include: Written in C++. No interpreted languages or proprietary libs needed.. Full plugin support. Multiple compiler support: GCC (MingW / GNU GCC), MSVC++, clang, Digital Mars, Borland C++ 5.5, and Open Watcom etc. Support for parallel builds. Imports Dev-C++ projects. Debugger with full breakpoints support. Cross-platform. Code::Blocks' interface is both customizable and extensible with Syntax highlighting, a tabbed interface, Class Br...

Supported OS id and their code in an installer

Hello frnd this is the code and thier Operating system id in windows ,to identify which program run in which windows The ID below indicates application support for Windows Vista -->           --The ID below indicates application support for Windows 7 -->           -The ID below indicates application support for Windows 8 -       supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" code provided to you by Rajlive360.tk

FIXED: Feedjit gadgets no longer work on my blog!!! help

well if your feedjit tracker is not working than you can easily fix this... goto blogger.com Go to  Dashboard -> Settings And set  HTTPS Redirect  to  No The gadgets will work now for  http ://yourblog.blogspot.com They won't for  https ://yourblog.blogspot.com because their connection isn't secure. this is not a permanent fix ... the gadget developers will have to make their gadgets https ready before Blogger will (if at all) become https only.

Color Code Generator

Instructions - Drag the bar on the "Hue" selector to the area of your desired colour palette.  - Then click inside the Brightness/Saturation area and drag the cursor until you have achieved your desired colour. The "Swatch" bar shows you the final colour result. - The hexadecimal colour code is generated in the "Hex" box. Simply copy the six digit code i.e #000000 How to add Hex Colour Code Generator To install Hex Color Code Generator on a Blogger/Blogspot page or post, copy the following code and paste it in the post or page HTML: <center><object border="0" classid="clsid:D27CDB6E -AE6D-11CF-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" height="480" id="obj1" width="480"> <param name="movie" value="http://www.2createawebsite.com/build/color.swf"><param name="qualit...

C Program to Sort Elements in Lexicographical Order (Dictionary Order)

#include #include int main () { int i , j ; char str [ 10 ][ 50 ], temp [ 50 ]; printf ( "Enter 10 words:\n" ); for ( i = 0 ; i < 10 ; ++ i ) scanf ( "%s[^\n]" , str [ i ]); for ( i = 0 ; i < 9 ; ++ i ) for ( j = i + 1 ; j < 10 ; ++ j ) { if ( strcmp ( str [ i ], str [ j ])> 0 ) { strcpy ( temp , str [ i ]); strcpy ( str [ i ], str [ j ]); strcpy ( str [ j ], temp ); } } printf ( "\nIn lexicographical order: \n" ); for ( i = 0 ; i < 10 ; ++ i ) { puts ( str [ i ]); } return 0 ;   }  https://www.jdoodle.com/embed/v0/c/gcc-5.3.0/6WK

Bypass Right Click Block on Any Website by java script

How JavaScript Works? Before you proceed to the next part which tells you how to disable the JavaScript functionality and bypass any of the restrictions imposed by it, it would be worthwhile for you to take up a minute to understand how JavaScript works. JavaScript is a client side scripting language (in most cases), which means when loaded it runs from your own web browser. Most modern browsers including IE, Firefox, Chrome and others support JavaScript so that they can interpret the code and carry out actions that are defined in the script. In other words, it is your browser which is acting upon the instruction of JavaScript to carry out the defined actions such as blocking the right-click activity. So, disabling the JavaScript support on your browser can be a simple solution to bypass all the restrictions imposed by the website. How to Disable the JavaScript? Here is a step-by-step procedure to disable JavaScript on different browsers: For Internet Explorer: If you are...

Flash and Unbrick Redmi 4 (India) [verified] [used by me]

Flash and Unbrick Redmi 4 (India) Please be noted I will not take any responsibility for anything happened to your device. Important: - Before flashing, it is advised to take the backup of data and make sure that your phone battery is charged enough. Note: This method will work with every ROM, Upgrade/Downgrade, Locked BL/Unlocked BL. Don't ask queries before reading the whole guide. NOTE: this guide is not written by ME . its by MUZ ..  When you can use Test Point for Flashing: 1. If a phone is totally dead, No Fastboot, No recovery. 2. If you are struck in Qualcomm USB 900e mode. 3. The bootloader is locked and a device is in bootloop. 4. You need to Flash Developer or Stable ROM on Locked BL. EDL Mode has been removed/Disabled from 8.1 onwards, you can flash on Unlocked BL only. Steps to Disassemble Redmi 4  (India)/4X: 1. Power off the Phone and remove the SIM Card Tray. You need below tools. 1. Anti-static angle tweezer 2....

5 Best Popular Posts Widgets For Blogger

Adding the Popular Posts Widget for Blogger Just click on your blog title, access the "Layout" menu, click "Add a Gadget" and choose "Popular Posts". A window will appear asking you to configure the widget by choosing which posts you'll feature (e.g. those that were most viewed in the past 7 days or 30 days or from the beginning of your blog). You'll also be asked to choose how many posts you'll feature in your Popular Posts section and select if you'll show the post title only or along with the image thumbnail and/or the snippet. (Remember that each widget style has different requirements, so follow the styles and instructions carefully to find out if you need the snippet and image thumbnail or not). Popular Posts Style 1 - Box within a box This is an interesting widget style since it uses your snippet and image thumbnail in a unique way. Your snippet is written in opaque text and placed in a small transparent box. This, in turn, ...