GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Wednesday, March 16, 2011

C - CMD Alternate Program

/**
 * This program is an alternatif for native cmd program in windows
 * But this version doesn't support for keeping the state.
 *
 * @author  : irfanudin ridho
 * @email   : irfan.ub@gmail.com
 * @version : 1.0
 * @date    : March 16, 2011
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "lola.h"

int main()
{
    system("color 2f");

    printf("Enter your command for cmd: ");

    // without malloc, the program will broke
    char *pause = malloc(sizeof(char));

    while(strcmp(pause,"exit") != 0){
        fflush(stdin);                  // free the buffer
        gets(pause);
        fflush(stdin);                  // free the buffer

        system(pause);
    }

    return 0;
}


Share/Bookmark

No comments:

Post a Comment