How can i print argv

Hello
How can i print all value for argv?
Is this code are ok?
Doest i need a terminal to see the result, or i can see it in c++ compiler?

1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
	int counter;
	for(counter=0; counter<argc; counter++)
		printf("argv[%2d]: %s\n",counter,argv[counter]);
	
	
	
} 
	return Exit.succses;
Last edited on
you cannot see it in the compiler, it is from the run time.
you do not have to have a terminal, a windows program can drop it into a messagebox instead of a console print, for example.

printf is C. use cout in c++ unless you have a reason not to. you are also using C includes, its <cstdio> and <cstdlib> in c++ and <iostream> for cout

the code you have is fine. well, almost, your return for main is outside of main and I think exit success is not right. Just return 0 or nothing at all or look up the proper exit success code.

Last edited on
Topic archived. No new replies allowed.