Thread: File io

  1. #1
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,246

    File io

    There is a .cpp file that has a function that should write in a file.
    I am using file.get(char) to read from a file, but it generates error in streambuf::sputc(). The file I am reading from, is a plain text.
    There is also a check for file.good(). After I disable that line program generates error on another line on another file, this time on a file.get() in streambuf::sbumpc().
    Error: First-chance exception in writer.exe: 0xC0000005: Access Violation.

    [edit]
    I was wrong errors occur even in an internal call.
    (But it worked once)
    [/edit]


    Last edited by siavoshkc; 02-05-2006 at 05:02 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Post your code.

  3. #3
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Code:
    ofstream OpenOfile();
    ifstream OpenIfile();
    Streams should not be copied around. Use references instead.
    Kurt

  4. #4
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,246
    Sorry for old headers, I am learning C++ from a book that uses old headers.
    "A Beginners' C++" it's a very good book.
    http://www.uow.edu.au/~nabg/ABC/ABC.html#
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  5. #5
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,246
    Thanks ZuK, it worked.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  4. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  5. File IO with .Net SDK and platform SDK
    By AtomRiot in forum Windows Programming
    Replies: 5
    Last Post: 12-14-2004, 10:18 AM