File io

This is a discussion on File io within the C++ Programming forums, part of the General Programming Boards category; There is a .cpp file that has a function that should write in a file. I am using file.get(char) to ...

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

    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]


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

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,499
    Post your code.

  3. #3
    ZuK
    ZuK is offline
    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,231
    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,231
    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, 04: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, 09:18 AM

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