fopen to return string?

This is a discussion on fopen to return string? within the C Programming forums, part of the General Programming Boards category; Hello, all. I'm having a bit of a problem (why else would I have made a new thread? ). How ...

  1. #1
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352

    fopen to return string?

    Hello, all. I'm having a bit of a problem (why else would I have made a new thread? ). How can I get fopen to return the contents of the file it read as a string? I've tried several things, but nothing seems to work.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    fopen doesn't read anything. It simply opens a file.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Jun 2009
    Posts
    457
    Once you have opened a file with fopen, if you want strings, read up on fgets()

    fgets - C++ Reference

  4. #4
    Premier Member
    Join Date
    May 2010
    Location
    Antarctica
    Posts
    31
    Or if you want straight up input from the file, use fscanf (functions exactly like scanf, but on the current "place" you are at in your file).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unable to compare string with 'getter' returned string.
    By Swerve in forum C++ Programming
    Replies: 2
    Last Post: 10-30-2009, 06:56 PM
  2. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 07:02 AM
  3. Inheritance Hierarchy for a Package class
    By twickre in forum C++ Programming
    Replies: 7
    Last Post: 12-08-2007, 04:13 PM
  4. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  5. lvp string...
    By Magma in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2003, 12:03 AM

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