Windows API is exactly that - an application programming interface for Windows. It has all of the necessary components to make Windows applications. There are form builders and I think Visual Studio C++ has one.
http://msdn.microsoft.com/en-us/library/bb384845(v=vs.100).aspx
This is probably a good place to try if you want to go that route. Bear in mind, you're working with a Windows specific API there. If you want cross-platform development, you'd need an alternative framework.
Look closely again at the code for the argv variable. It's not a char, it's an array of C-strings (you could write it as
char **argv
if you prefer). They are picked up from whatever you pass in when you run the program from the command line (or, in some IDEs, you can set command line argument through some build settings).
So, if I had:
Then argc would be three. Remember, the first argument is always the program name. The second and third would be "hello" and "world" respectively. And since we start are indices at zero, those three arguments are stored in argv[0], argv[1] and argv[2].
In essence, that's all they are - strings. You can pass whatever file type you like, provided you've coded the adequate solution to read it in your program.
Here's a basic example. Let's assume we have a text file, my_file.txt, in the same directory as our program. It looks like this:
my_file.txt
Line One
Line Two
Line Three
|
And then we have our program. We're going to take the name of the file from the argument passed in and, providing we can open it, print its contents to the screen.
args.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#include <iostream>
#include <string>
#include <fstream>
int main( int argc, char* argv[] )
{
std::string line;
if( argc < 2 )
{
std::cout << "No argument passed to program\n";
std::cout << "Usage: " << argv[0] << " <filename>\n";
return 0;
}
std::ifstream is( argv[1] );
if( is.is_open() )
{
while( getline( is, line ) )
std::cout << line << std::endl;
is.close();
}
else
std::cout << "Could not open file " << argv[1] << std::endl;
return 0;
}
|
So, if I compile the program, name it 'args' and run it.
> args my_file.txt
Line One
Line Two
Line Three |
Does that clear anything up?