-
Command line arguments
I am trying to retrieve the command line arguments that are given to me.
I am using msvc++ 2008
Code:
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <string>
int _tmain(int argc, char* argv[])
{
std::cout<< *arg[0] << std::endl;;
std::cout<< argc;
return 0;
}
The above gives me
j (the file name is jplib.exe)
x = (the amount of arguments I give +1)
If I change it to *arg[1], and I have one argument will give me the first letter to the first argument, and *arg[2], the first letter to the second argument, etc.
I have tried using arg[1][1], but that returns null
How do I get the command line arguments?
Thank you for your time and effort,
Joe
-
-
And use main if you use a char argv, not _tmain. _tmain is the Win32 Unicode switchy thing, and if you don't know what that means, you should use main.
-
Specifically: http://faq.cprogramming.com/cgi-bin/...&id=1043284392
Note that double semicolons are entirely unnecessary. :) And <vector> and <string> are too, but let's assume you're going to use them later on . . . .