Thread: Opening a file with my application...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    55

    Opening a file with my application...

    I'm writing a video player. When you open it you can browse for the video file to open via an open file dialog. The string I get with that I send it to the function that has the fopen. It works.

    Also, if I comment the open file dialog and get the file path via parameters, it works.

    However, if I use "Open With..." from Windows, and send the path I get from the parameters (I checked, it's the correct path), the fopen fails. Why is that?

  2. #2
    Registered User
    Join Date
    Apr 2007
    Posts
    55
    It's between " "! I'll take them out, manually. Any easy way to do it?

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Look at the error status of fopen, and let it tell you why.

    fp = fopen( blah, "rb" );
    if ( fp == NULL ) perror( "humbug" );

    Or strerror() if you want a string for a popup.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 07:54 AM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM