Re: passing a filename to main()



You need to go read a basic "C" programming book.

char *inpname 

just allocates a pointer, not a block to hold the name
you are trying to copy using the strcpy.  On a modern
operating system you should get a memory exception.

Doug

On Mon, 2006-03-06 at 17:14 +0100, Mickael Drean wrote:
> Hi there,
> 
>  I tried to specify a file to load to my application on startup but it
> didn't works. At that moment I tried to only show the name of the file
> specified.
> 
>  Here is my code :
> 
> int main(int argc, char *argv[]) 
> {
>     
>     Gtk::Main kit(argc, argv);
>     
>     if (argc > 1)
>     {
>              char* inpname;
>              strcpy(inpname,argv[1]);
>              printf(inpname);
>     } 
>     
>     CMyApp App; 
>     Gtk::Main::run(App);
>     
>     return 0;
> }
> 
> 
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]