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?

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"
.

thanks, that solves my problem perfectly!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.