Overwriting a line in CSV file with C++ -
i'm writing payroll program in c++ , need able read lines in file, calculations, , overwrite read lines in file. there function/way can overwrite specific lines, insert new lines, add onto end of existing file?
there no c++ functionality "insert" or "remove" text in text-file. way read existing text in, , write out modified text.
if new text fits in same space old one, need overwrite existing text - , of course, can add spaces before/after comma in .csv file, without becoming part of "field". if new data longer, won't work "overwrite in place".
adding end relatively easy using ios_base::ate
modifier. inserting in middle still involves reading until find relevant place, , then, if new text longer, have read following lines before can write new one(s) out.
Comments
Post a Comment