Using Microsoft Visual C++ 6.0
Using Microsoft Visual C++ 6.0
This latest version of Visual C++ forces us to work with a project rather than a simple, stand
alone C or CPP source file. This is the way that you would prefer to work for a real project but it
does add undesirable complexity at this stage of the students C and/or C++ knowledge. Working
with a single C or CPP source file is very desirable from a training perspective as it allows the
student to focus on the language and task at hand and not operating system specific complexities.
This is a very powerful tool that has been optimized to do Microsoft Window’s programming,
not C or C++ training.
You must specify a drive and path to store your files and a project name. The project name will
be used by Visual C++ to automatically create a subdirectory of that same name. All of your
project files (just a single .c or .cpp file for our needs) will be in this subdirectory plus other files
that are automatically generated by Visual C++. You can have as many c, cpp, or h files as
required for your project but they may contain only a single instance of the function called
main().
For all of the C and C++ courses we will be creating a Win32 Console Application which is a
DOS box, NOT a Win32 Application which is a true Windows application and requires much
more code than we are presently prepared to write. All of the C and C++ course exercises are
console types of applications that will run under DOS, UNIX, any other type of command line
driven operating system, or under Windows as a DOS box. It is necessary to learn to work with
these types of applications first before going on to much more complex GUI applications such as
Microsoft Windows. First, there are still ample applications for command line applications,
particularly on UNIX and mainframe systems. Second GUI programming adds a considerable
amount of complexity and it just isn’t realistic to start at that level. To do GUI programming
requires a good skill level in C++ that implies at least a solid working knowledge of C.
The character ‘|’ is used to separate menu choices.
Run Visual C++ from Windows 95 or NT 4.0.
Pick Start
Pick Programs
Pick Visual C++
Pick Visual C++ from the child menu
DeepSoft, Inc. Engineering – Programming – Training
6259 Deep River Canyon, Columbia, MD 21045-2572
Phone: 410-312-2982 Email: tkf@deepsoftinc.com
Fax: 410-312-3067 Web: http://www.DeepSoftInc.com
Create a project
Pick File | New
Select Win32 Console Application
Specify a drive and path by picking the button to the right of “Location”
Give the project a name
Pick OK
Select “create an empty project”
All of your code will go into a subdirectory with the project name
Create an empty C or CPP source file
Pick File | New
Pick C++ Source File (even if it’s a C program)
Give it a name (add .c for C files, .cpp is the default)
Click on the “Add to Project” check box
Pick OK
If you forgot to check “Add to Project”, or want to add a previous source file
Pick Insert | File as text
Select the file
Once in a project, File | New will always attempt to add another source file (C, CPP, or h)
which is fine for real projects but unnecessary for our problems which will all be done in
a single C or CPP source file.
Write, Edit, & Build Code
Now add your code to the C or CPP file.
Save it with File | Save
Build the project with Build | Build filename.exe
Or
Rebuild the project with Build | Rebuild All
Or
Compile only with Build | Compile filename.c
Run with Build | Execute
There are also icon buttons in the upper right corner of the menu bar to do these things.
To do the Next Problem
Go back to the top and start a new project
You may want to copy source code from a previous project or, if several problems are
related simply add all the code to one source file in a project.
To open a previous project
File | Open Workspace
To open just a file (you normally want to open a project which is a workspace)
File | Open
To open recent files or workspaces
File | Recent Files
File | Recent Workspaces
After you run your application, you must close its window to be able to do any additional
development. The linker cannot overwrite a running program.
To copy all of your .c or .cpp files from the network drive to your floppy disk
Open Windows Explorer and look at your floppy (leave Explorer open)
Start | Programs | Windows Explorer
Use the File Find capability to actually find all of the files
Start | Find | Files or Folders
Set Named = *.c or *.cpp
Pick Browse and go to: N:\Cclass\section number\your name
Pick include subfolders
Pick find
Once found select all with Edit | Select All
Copy with Edit | Copy
Go back to Windows Explorer and paste to floppy with Edit | Paste
No comments:
Post a Comment