I'm removing a line from my file.
User enters record. And the line containing record in the beginning is replaced by SPACES.
(This is what I thought to delete a line).
Problem is is.tellp() in os.seekp(is.tellp()); at line 12 in code. When I write ios::cur in place of is.tellp() Error is removed. But I've to use is.tellp() here in os.seekp(is.tellp()); But this causes Error.
Error:
--------------------Configuration: b - Win32 Debug--------------------
Compiling...
b.cpp
D:\VC 6.0\b\b.cpp(77) : error C2664: 'class std::basic_ostream<char,struct std::char_traits<char> > &__thiscall std::basic_ostream<char,struct std::char_traits<char> >::seekp(long,enum std::ios_base::seekdir)' : cannot convert parameter 2 from 'clas
s std::fpos<int>' to 'enum std::ios_base::seekdir'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.
Suppose my file a.txt has "ABC" written in it. Now I want to write a small b before capital B in the file. How will I do it. I've tried to do it but i'm having problems.
1. When opened in app mode seekp doesn't work.
2. When opened normally previous written data is erased.
I do not reccomend to open one file in several streams. Close one before opening in other.
Several possibilities:
1) Write data to another temporary file then replace original with it. (Widely used)
2) copy data afrer "A" to temporary buffer, write "b" after "A", write temporary buffer (uses too much memory for large files)
3) Write last character after last character ("ABCC")
write previous-to-last char in place of last ("ABBC")
etc...
Write character you vant to insert ("AbBC")
(Slow)
How the 2) and 3) points are done?
2) How to copy data to temporary buffer temporarily and then write to appropriate location?
3) How to write previous-to-last char in place of last?