logoISU  

CS456 - Systems Programming

Spring 2026

Displaying ./code/jan28/printargs.c

/*

printargs.c - prints the command line arguments in order, one per line 

argc - "argument count": the number of arguments passed through
argv - "argument vector: array of strings where argument is stored
	can be depicted as *argv[] or **argv

Compilation and Output: 
	> gcc -o printargs printargs.c
	> ./printargs hello world
	./printargs
	hello
	world

*/

#include <stdio.h>

int main(int argc, char *argv[]){
	
	//setting up for loop to loop through arguments
	for(int i = 0; i < argc; i++)
		printf("%s\n", argv[i]); //print each argument in a new line

	return 0;
}