I wanted to write a program that can open a txt file directly through the operating system.
What i mean to say is that when you see a txt file i must be able to double click on it and it is directly opened by my program....like notepad can..........
The first argument passed to your program is the program filename, when opening a file also that argument is passed.
So you need to make your program recognise it:
1 2 3 4 5
int main ( int argc, char **argv )
{
if ( argc==2 ) // one argument was passed
fstream( argv[1] );//try to open that file
}
Then you need to make your system know that your program is the default for that file type