john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

dos system

/* john pfeiffer 08feb08 demo of system command in c to access the dos commandline */

#include <stdio.h>
#include <stdlib.h>     /* necessary for dos headers */

int main()
{
    int i=0;

    printf ("Checking if processor is available...");
    if (system(NULL))
    {   puts ("Ok");    }
    else
    {   
        puts("Processor not available?");
        exit (1);
    }

    printf ("Executing command DIR /B...\n");
    i=system ("dir /b");
    printf ("The value returned was: %d.\n",i);
    puts("0 means the command executed successfully, 1 means the command failed.\n");

    printf ("Executing fake command DIRS...\n");
    i=system ("dirs");
    printf ("The value returned was: %d.\n",i);
    puts("0 means the command executed successfully, 1 means the command failed.\n");

    return 0;
}

  • « time get
  • file extract non html »

Published

Feb 8, 2008

Category

c

~93 words

Tags

  • c 95
  • dos 6
  • system 9