GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Tuesday, January 25, 2011

Command Line Argument In C

#include <stdio.h>

/**
 * @param argc int how many words type in command line including
 * app file. start from one.
 * @param argv array of string how many words in the command line.
 * start from app file as zero index.
 *
 * try by typing: lol.exe welcome to Americas
 * the result would be:
 *   0. lol.exe
 *   1. welcome
 *   2. to
 *   3. Americas
 */

int main( int argc, char *argv[])
{
    int i;

    for( i=0; i<argc; i++)
        printf("%d. %s\n", i, argv[i]);

    return 0;
}

Share/Bookmark

No comments:

Post a Comment