User Profile

Collapse

Profile Sidebar

Collapse
ishould
ishould
Last Activity: Oct 18 '09, 03:58 AM
Joined: Oct 15 '09
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • ishould
    replied to Can you use seekp without ios::binary?
    in C
    Sorry for the triple post, but I figured it out so I thought I should post my findings for future reference. It seems weird but this works:

    ofstream File;
    File.open("file .txt", ios::in); //notice the ios::in, this is what made it work
    File.seekp(8, ios::beg);
    File << "four";
    File.close();
    See more | Go to post

    Leave a comment:


  • ishould
    replied to Can you use seekp without ios::binary?
    in C
    *bump* Theres really no way to do this? Is my only option to convert the whole file to binary?
    See more | Go to post

    Leave a comment:


  • ishould
    replied to Can you use seekp without ios::binary?
    in C
    when I change File << "four"; to File.write("fou r", 8); all that shows up in the file is "four" eight characters from the start of the file, everything else is gone
    See more | Go to post

    Leave a comment:


  • ishould
    started a topic Can you use seekp without ios::binary?
    in C

    Can you use seekp without ios::binary?

    My actual problem is much larger but figuring out how to do this example will help me. I want to overwrite data that already exists in a text file but I can't seem to do this.

    ex.
    [file.txt]
    I have five fingers.

    My current code:

    Code:
    ofstream File;
    File.open("file.txt", ios::out);
    File.seekp(8, ios::beg);
    File << "four";
    File.close();
    ...
    See more | Go to post
No activity results to display
Show More
Working...