Presentation is loading. Please wait.

Presentation is loading. Please wait.

 CSC 215 : Procedural Programming with C C Compilers.

Similar presentations


Presentation on theme: " CSC 215 : Procedural Programming with C C Compilers."— Presentation transcript:

1  CSC 215 : Procedural Programming with C C Compilers

2  In the Lab, Your saved C program will be displayed with a Microsoft Visual Studio or Java icon.  GCC: The classic open source C compiler for Linux and many other operating systems (and Windows under Cygwin or Ming).  Xcode. This is for Apple Mac and it is their version of GCC.  There are many other C compilers.

3 GCC Compiler  If you're on Linux, you can use gccgcc  If you're on Mac OS X, you can use XCode.XCode  XCode is free - it comes on your install CDs. Install it.  To get the latest version of Xcode, you can download it from Apple’s website.  If you are on Windows, you can use Cygwin.  Cygwin is a large collection of GNU compiler collection (GCC) and Open Source tools which provide functionality similar to a Linux distribution on Windows.

4 GCC Command  gcc invokes C compiler  gcc translates C program into executable file  $ gcc hello.c –o hello  Default output file name a.exe, to run output file,  $./hello

5 Download and Install Cygwin Compiler  Step 1: Download Setup Download the setup program "setup.exe" from www.cygwin.com.  Step 2: Run Setup to Select, Download & Install Cygwin Packages  Run "setup.exe" ⇒ Install from Internet ⇒ select a directory (avoid installing in "Program Files" because of that "blank" character) ⇒ choose "Local Package Directory" which saves the downloaded installation files ⇒ select your Internet proxy setting ⇒ choose a download mirror site. (If "choose download site" box is empty, add "ftp://mirror.averse.net/pub/cygwin" in the "User URL". You can find all the mirror sites from http://cygwin.com/mirrors.lst.)  Select the packages to install.  Important: open the "Devel" (Development) category and select "gcc", "make",  Step 3: Setup PATH Include the Cygwin Binary directory (bin) in the PATH environment variable.  Suppose that your Cygwin is installed in directory "c:\cygwin". From "Control Panel" ⇒ System ⇒ (Vista only) Advanced System Settings ⇒ Advanced ⇒ Environment Variables ⇒ System Variables ⇒ Select variable named "PATH" ⇒ Edit ⇒ Add "c:\cygwin\bin;" in front of the existing PATH entry. Note that the semi-colon serves as the directory separator to separate Cygwin from the rest of directory paths.

6  Installation Steps Link :  https://www3.ntu.edu.sg/home/ehchua/programmin g/howto/Cygwin_HowTo.html

7 Creating a Folder  Open the Cygwin terminal  Go to the target directory (desktop) using the command cd:  cd writeThePathHere  Create a folder called “yourName_CSC215”using the command mkdir:  Mkdir yourName_CSC215

8 Write, Compile, Run your first C Code  Inside your folder open the text editor, save it with the extension.c, name it using the following naming convention:  “Lab1_YourFirstName_YourLastName.c"  Don’t forget to move to your own directory  Write, compile and run a program that prints: Hello World!  To compile the code type gcc -o Lab1_YourFirstName_YourLastName Lab1_YourFirstName_YourLastName.c  To run the code type./Lab1_YourFirstName_YourLastName  Show the program to your lab instructor.

9 Evaluation Question  Write a C program that declares a char variable, say, CH, and initializes it to any lowercase letter, ex: CH = b. The program should print the character CH and print in a new line the three characters that follow the CH character in the alphabetical order.  Note: In your answer don’t change the value of CH and don’t use any other variable.  Compile and run your program.  Output:


Download ppt " CSC 215 : Procedural Programming with C C Compilers."

Similar presentations


Ads by Google