logoISU  

CS256 - Principles of Structured Design

Fall 2021

Displaying ./code/cs256su21code/jun29/cmdargs.c

/*

demonstrating command line arguments

every command you use in linux handles commands this way

the parameters are int argc: - the argument count, or how many arguments
							   were typed on the command line.

			   char *argv[]: - argument vector: everything you type is stored here as strings

argv[0] - usually the program/command name
argv[1] - the first argument after the command name


*/
#include <stdio.h>

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


//this just prints out what you've typed on the command line
	for(int i = 0; i < argc; i++){

		printf("argv[%d]: %s \n", i,  argv[i]);

	}

	printf("argc = %d\n", argc);

	return 0;
}