problems opening a files

This is a discussion on problems opening a files within the C Programming forums, part of the General Programming Boards category; hey there happy hunters!! I need yet more help!!!! I'm trying to open a file using a string from a ...

  1. #1
    Registered User the bassinvader's Avatar
    Join Date
    Jul 2006
    Location
    Europe
    Posts
    51

    Smile problems opening a files

    hey there happy hunters!!

    I need yet more help!!!!

    I'm trying to open a file using a string from a structure
    but it keeps failing to open. I know the enirety of the code is fine
    it's just this little bit....

    Code:
    if((ptr=fopen(dir->d_name,"rb+"))!=NULL)
    I'm trying to open files from a directory so maybe the problems there?!
    There doesnt seem to be a newline hidden at the end so can
    anybody offer a little help. I'm sure its simple, so any help
    would be appreciated.

    thanx

    ( Windows xp, Dev-c++(4.9.9.0))

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    What does the string look like?
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    176
    is the pwd the directory containing the files?
    otherwise you would have to supply a full path, not just the filename

  4. #4
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682
    Code:
    dir->d_name
    hey this give you just the file name, it donst give the path. if this file name contains in the current directory then the file will be opened.

    ssharish2005

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Notepad++ opening ActionScript files
    By sean in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 08-26-2008, 03:49 PM
  2. Opening files.
    By omnificient in forum C Programming
    Replies: 9
    Last Post: 02-25-2008, 01:05 PM
  3. Opening ASCII files in C?
    By Mavix in forum C Programming
    Replies: 6
    Last Post: 04-25-2007, 02:23 PM
  4. opening files sequentially
    By barneygumble742 in forum C++ Programming
    Replies: 9
    Last Post: 12-21-2006, 10:26 AM
  5. Opening files - Giving options?
    By wwwGazUKcom in forum C++ Programming
    Replies: 3
    Last Post: 09-18-2001, 07:06 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21