SETTING UP MSOE LAPTOPS FOR WINDOWS C CONSOLE APP DEVELOPMENT

Microsoft Windows does not install a C development environment by default. However, configuring MSOE laptops for development is quite easy.

Microsoft Visual Studio provides a complete integrated development environment for applications that run within the Windows frameworks as well as applications that run from the command prompt. While Visual Studio is an excellent environment, it's complexity can be much to learn when simple applications are all you desire to create. Luckily, Visual Studio also installs a full set of command line tools so that applications can be created outside of the more complex integrated development environment. Use this process to configure your laptop for quick-and-easy console application development. You must be on the MSOE domain to follow this instruction set. Consult with the IT Help Desk if you have imaged your laptop on your own and need to have your laptop attached to the domain.

DEVELOPING CONSOLE APPLICATIONS PART 1: EDITING

HelloWorld Project main.c


/* filename: main.c
 * project:  HelloWorld
 * author:   meier@msoe.edu (Dr. M.)
 * to use:   hello [namestring] [spanish english french chinese] 
 * arguments: 
 * - optional namestring 
 * - optional language 
 */

// include library functions 
// - stdio: printf     
// - string: strcmp
#include <stdio.h>
#include <string.h>

// declare user enum type for language
typedef 
enum languages {english, spanish, french, chinese} language;

// main
int main(int argc, char** argv)
{
  // process command line arguments
  // check for language: default to english
  language outputLanguage = english;
  if(argc == 3)
  {
    if(strcmp("spanish",argv[2])==0) outputLanguage = spanish;
    else if(strcmp("french",argv[2])==0) outputLanguage = french;
    else if(strcmp("chinese",argv[2])==0) outputLanguage = chinese;
  }
 
  // do output
  switch(outputLanguage)
  {
    case spanish: 
      printf("\nHola %s!\a\n",argc>1?argv[1]:"");
      break;
    case french:  
      printf("\nBon Jour %s!\a\a\n",argc>1?argv[1]:"");
      break;
    case chinese: 
      printf("\nNi Hao %s!\a\a\a\n",argc>1?argv[1]:"");
      break;
    default:      
      printf("\nHello %s!\n",argc>1?argv[1]:"");
      break;
  }
  return 0;
}

DEVELOPING CONSOLE APPLICATIONS PART 2: COMPILING