MAE152 -- Fall Quarter 2003

Visual C++ FAQ


This page was last updated: 9/10/03


  1. How does C differ from Fortran 77? Click here to find out.

  2. How does C++ differ from C? C++ has a lot of object-oriented features, such as classes, methods, procedure overloading, operator overloading, etc. In CSE 167, we will just be using C, not C++.

  3. How does one start up Visual C++? Click Start-Programs-Microsoft Visual C++ 6.0-Microsoft Visual C++ 6.0

  4. How do I enter a program into VC++? After initiating VC++ as described above: Click on File-New. It will then ask you what type of project you want to create. You want to create a Win32 Console Application as shown below:

    On the same page, you will be asked to name your project and specify where to put this folder. Specify something in your home area, H:\mylogin\Projxx.

    When you are asked what kind of console application you want to create, respond with: An Empty Project.

    Don't get confused about all this talk of "projects" and "workspaces" in VC++. To you, it really all means "project folder". You should create one "project/workspace folder" per programming assignment.

  5. Then what? Click on File-Open. This will let you open a file. This could either be all.c or could be a previous assignment you want to build upon.

    You can re-save that file into your project folder if you want. That will keep it distinct from other C files in your area.

    However, you do not need to re-save that file into your project folder. Once you make it part of your project by answering Yes during the compilation (see below), VC++ will remember where to find it.

    Start doing whatever editing you need to do.

  6. How do I compile and link my C program? To compile, click Build-Compile. If it asks if you want to make this file part of the project, answer Yes. If there are compilation errors, they will show up in the little box at the bottom. If you double-click on a compiler error, you will be taken right to the line in your program that produced the error.

    If there are no compilation errors, then click Build-Build. This will link in the necessary libraries.

  7. How do I be sure the OpenGL libraries are linked in? Before you Link, click Project-Settings. In the resulting dialog box, click on the Link tab. In the Object/library modules area, be sure the list of libraries includes:

    glui32.lib glut32.lib glu32.lib opengl32.lib

    at the front of the list and in that order, as shown here:

  8. How do I run my program? If there were no compile or link errors, click Build-Execute.

  9. Are there icon shortcuts for the Compile-Build-Execute process?

    On the right side of the screen, you will see the following icons:

    From left to right, they stand for:

    CompileBuild-Execute--

    where - stands for icons we don't care about right now.

  10. What are the best ways to debug my C programs? There are a lot of debugging utilities in VC++, but you will probably find that printing helpful status messages works best of all.

  11. How do I write to the console window? Use the fprintf() C print routine and print to a "file" called stderr. This will print to the console window. For example:
    fprintf( stderr, "x = %6.2f, y = %6.2f\n", x, y );
    

    Do not use printf() for debugging messages! printf() buffers its messages, so there is no syncronization between what you see on the graphics screen and what you see in the text console window.

  12. How do I write debugging messages to a file from a C program? Here is an example:

    #define DEBUGFILE	"debug.txt"
    
    	. . .
    
    FILE *fp;
    
    	. . .
    
    
    fp = fopen( DEBUGFILE, "r" );
    if( fp == NULL )
    {
    	fprintf( stderr, "Cannot open '%s'\n", DEBUGFILE );
    	exit( 1 );
    }
    
    	. . .
    
    fprintf( fp, "x = %6.2f, y = %6.2f\n", x, y );
    

  13. If I log back in later, how do I get back into Visual C++ to edit my program some more? Double-click your way into your project folder, then double-click on your Developer Software Workspace (*.dsw) file.

  14. Can I run my program without entering Visual C++? Double-click your way into your project folder, then double-click on the Debug folder, then double-click on your executable (*.exe) file.