 |
CS 2073 Engineering Programming
Running C Programs, Spring 2006
|
Available Systems to run C:
- Microsoft Visual Studio C++ 6.0:
This is the software I assume you will use for the course.
It is now somewhat dated, but that won't matter for us.
It is available in the classroom, and in the Business Building.
It is not available in the CS lab: Science Building 1.02.04.
- Microsoft Visual Studio .NET:
This is also available in the classroom and in the Business Building.
Unless things change, it is not usable in the CS lab: SB 1.02.04.
This software is newer and a little harder to use than
6.0 above.
- C/C++ compiler from bloodshed.net:
This is a much smaller system, free to download and easier to use
than Visual Studio, but similar to it.
A student from last semester particularly recommended this compiler,
with a download at:
http://www.bloodshed.net/devcpp.html.
- C/C++ under Unix or Linux: This is what CS students
might be more likely to use. Fairly hard to learn to use, and
of course not under Windows.
- Any other C/C++ you have access to.
Using Microsoft Visual C++ 6.0:
Fortunately, there are simple steps that allow us to run
a simple C program without using much of the features available
with this very complicated software.
Here are the simplest steps that I know of. I will use them class:
- From the "Start" button, go up to
"Microsoft Visual Studio 6.0" and then to
"Microsoft Visual C++ 6.0". Click on this program to start it up.
- Pull down the "File" item at the upper left, and click
on "New".
- In the box provided, click on the "Files" tab.
- In the list provided, click on "C++ Source File".
- You can enter a name is the place provided, say in the
first example dist.c, or just use the default name.
- Click on "OK" in the box.
- Now a white area will appear, where a C program belongs.
- Use copy and paste or just enter a C program that you
want to run.
- Pull down the "Build" item at the upper middle, and click
on "Compile". (Click "Yes" to the question about a project
file not existing, or click "Yes" to the question about overwriting
an existing project file. Note that this may overwrite your last project.)
- Pull down the "Build" item at the upper middle, and click
on "Execute". (Click "Yes" to the question about an executable
file not existing, or click "Yes" to the question about overwriting
an existing executable file. Note that this may overwrite your last executable.)
At this point, a black window will appear that holds the output
of your program. If you have to enter any data for the program,
it will appear in this box.
Making up a file for program submission:
Open an empty Notepad window ("Start" --> "Accessories" --> "Notepad").
- Copy the original program from Visual Studio (using mouse
selection and ctrl-c),
and paste it it into the Notepad window (using ctrl-v).
- We want to copy the output in the black window into the Notepad
window at the end. In order to do this, use a sneaky little
icon at the extreme upper left of the black window.
By pulling down a menu from this icon, you can select everything in
the black box, and copy it for later pasting.
- Use ctrl-v to paste the copied contents of the black box
(the results of executing the program)
into the Notepad document after the program source.
- You can get access to the file inside the Notepad
by emailing it to yourself. One easy way is to use your UTSA
Lonestar account to email it to yourself (or elsewhere):
https://lonestar.utsa.edu/webmail/
or you could store in into a USB stick or even (gulp!) a floppy disc.
- We can also use the sneaky icon of step 2 to copy input into
the black window, instead of having to type all input by hand.
- Now go on to the directions for submitting the program and
its output: Submission directions.
Under Bloodshed, keeping the black box from disappearing:
If you use the Bloodshed.net compiler, you will need some
way to keep the black
box from disappearing?
One method is to include an extra (redundant) "scanf" statement (or something like it) at the
end of your program, so that at the end of your run, everything will pause
while it waits for you to enter data. One possible form of this method
looks as follows, where you add the stuff in
red below.
(Go ahead and add it whether you understand it or not.)
int main() {
int dummy; /* new declaration just after the "main" line */
/* the inside of your main function here */
scanf("%d", &dummy); /* clear at the end, but before "return" */
return 0; /* if you have a return -- it's not needed */
}
By the way, in Bloodshed, you can use the same little icon at the
upper left to select all, and copy (or to paste) using the
black box.
Revision date: 2006-01-22.
(Please use ISO
8601, the International Standard.)