0

Cant seem to figure this one out,,,, although I have been trying for several hours and cant seem to find any good examples on the WWW...

I am attempting to write a program that prints the command-line arguments
of a program...

I did find a example that gives the Name of the program and attemps to find
the argrments to print,,,,,, but does not seem to work...

AnyOne got some Ideas?????? :-O :-/

#include "stdafx.h"
#include <stdio.h>
#include <conio.h>


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

	printf("This program is named %s.\n", argv[0]); 


	for (i = 1; i < argc; ++i)    

		printf("the argument #%d is %s\n", i, argv[i]);   

	getch();

	return 0;
}
4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by WaltP
0

I'm assuming you are using VC++ ? Go up to Project/"Your Proj Here Properties"/Configuration Properties/Debug/Command Arguments and put something for it to print out (separated by spaces).

If you're not using VC++ then just put some arguments after your exe name when you are running it. "myexe -parameter1 -parameter2" (you don't need the dashes in this case they're just for effect).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.