COS 126
Compiling from the LCC-Win32 IDE |
Programming Assignment 0
Due: Thursday, 11:59pm |
These instructions are designed for students using LCC-Win32
which runs the C IDE on Windows machines.
Don't be afraid to ask for help.
Your assignment is to create, compile, and run the following extension
of everybody's first C program.
#include <stdio.h>
int main(void) {
int num;
printf("Hello world! Give me an integer:\n");
scanf("%d", &num);
printf("Thanks! I've always been fond of %d.\n", num);
return 0;
}
Completing this assignment involves a number of steps that are
described below.
Now you are ready to write your first program.
- Be certain to follow the documented setup instructions for LCC-Win32.
-
To begin the process, make sure you have created a folder titled
C:\cos126. Then, goto
Start -> Programs -> lcc-win32 -> lcc-win32. In the LCC-Win32 window,
goto File -> New -> Project and enter hello and press
ENTER. Under Path Working Directory, enter the \cos126 path you created
for all of your COS 126 files, such as
C:\cos126\hello and press ENTER four times.
- Make sure Ansi-C only is selected under
Language extensions. Moreover, make sure the Warning level
is set to All and press ENTER.
- Change the Output file name to
C:\cos126\hello\hello.exe instead
of C:\cos126\hello\lcc\hello.exe essentially removing the
extra directory necessary in order to access the executable file. Press
ENTER twice.
-
Enter the C program exactly as it appears above, erasing everything else.
If you omit even a semicolon, the program won't work. Use the Tab key to
get the proper indentation. When you're done, save the program.
-
It is now time to convert your C program into machine executable code.
In the IDE interface, before the first time you compile any
new project (not a new file), you must goto the Compiler tab and make
sure Ansi-C only is selected under Language extensions.
Moreover, make sure the Warning level is set to All.
Regardless of whether it is a new file or project, you must now goto
Compiler -> Compile hello.c in order to compile the file.
-
In the IDE interface, goto Compiler -> Execute hello.exe.
This command executes your program. You should get
Hello world! Give me an integer:
in the
window. Then nothing will happen. You must type an integer (say, 5),
and hit Enter, then you will get
Thanks! I've always been fond of 5.
and the program should terminate. You may need to repeat this
edit-compile-execute cycle a few times before it all goes smoothly.
Most of this material was provided from the page created by
Robert Sedgewick.