hi again :)

i was wondering how i would make a file automatically open with a program, eg:
like after you install dev c++, .cpp files automatically open in the editor. how does the editor get the file's location? and how does it process it?

9 Years
Discussion Span
Last Post by scratchnloved

i meant passing the file's name and such as paramaters to a program. How do i get that information?

for that matter, how do you make an executable recieve arguments from the command line?


all c and c++ programs have a main() function, and it has two optional arguments. int main(int argc, char* argv[]) argc is the number of command-line arguments (deliminated with spaces). argc is always > 0 because the first argument is the name of the executable program.

argv is a character array of the arguments. argv[0] is (usually) lways the program's name

To if you type c:>myprog Hello World <Enter key> In the above, argc == 3,
argv[0] = "myprog"
argv[1] = "Hello"
argv[2] = "World"

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.