problem in the reading of my file .text

This is a discussion on problem in the reading of my file .text within the C++ Programming forums, part of the General Programming Boards category; Hi, I have problem in the reading of my file .text i open it like that Code: FILE *fp; fp=fopen("my_file","r"); ...

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    57

    problem in the reading of my file .text

    Hi,
    I have problem in the reading of my file .text
    i open it like that
    Code:
      FILE *fp;
    fp=fopen("my_file","r");
      if (fp != NULL)
    
         {
    ..................
    }
    else printf("null");
    he open the file but he find it null , he pront to me "null"
    but my file not null
    where is the problem?

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,403
    This is in the wrong forum - you are using C
    You probably have your filename / path wrong - my_file i imagine is my_file.txt or something like that - you need to specify it exactly - and it will only work like that (without a path) If you are opening it in the same folder as your binary - you should always define the whole file path + name anyway - use args / input to retrieve it or hardocde it exactly as it should be
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  3. #3
    Registered User
    Join Date
    Apr 2012
    Posts
    57
    i work in c++ ,
    yes my file is in the same folder as my binary

  4. #4
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,403
    you may well work in c++ but that example is written in C - and posted in the C++ forum

    what is the actual name of your file? does it have an extension part?
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  5. #5
    Registered User
    Join Date
    Apr 2012
    Posts
    57
    hi,
    i used c instructions to read my file , but now i want store the data in vector
    that's description of my problem
    problem with reading floatting numbers

  6. #6
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,403
    so post in the c+ forum - if one exists
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem with reading ints from a text file into an array.
    By csharp100 in forum C Programming
    Replies: 3
    Last Post: 10-20-2012, 12:40 PM
  2. Problem reading in Text File
    By voidpain() in forum C Programming
    Replies: 7
    Last Post: 08-10-2011, 07:50 PM
  3. Replies: 8
    Last Post: 05-05-2010, 02:43 PM
  4. Reading Text File (spaces problem)
    By kekewong in forum C Programming
    Replies: 1
    Last Post: 04-15-2009, 03:34 PM
  5. problem reading a text file.
    By jerrykelleyjr in forum C Programming
    Replies: 13
    Last Post: 10-25-2006, 06:18 AM

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