| | |
copying in files
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
>we should be able to append file1 anywhere in file2
Append? Or insert? Appending always adds new data to the end of the file, but inserting can add new data anywhere in the file. Appending is easy because C and C++ support an open mode for files that strictly appends:
Inserting is harder because, unless you use record oriented files, you can't actually insert into a file. You need to use an intermediate working file to copy the first chunk of the output file, then the input file, and then the second chunk of the output file, just like inserting a substring into a C-style string:
Append? Or insert? Appending always adds new data to the end of the file, but inserting can add new data anywhere in the file. Appending is easy because C and C++ support an open mode for files that strictly appends:
C++ Syntax (Toggle Plain Text)
open input for reading open output for appending while there's another line in input write line to output close output close input
C++ Syntax (Toggle Plain Text)
open input for reading open output for reading open scratch for writing while not at the insertion point in output write line to scratch while there's another line in input write line to scratch while there's another line in output write line to scratch close input reopen output for writing reopen scratch for reading while there's another line in scratch write line to output remove scratch close output
I'm here to prove you wrong.
![]() |
Similar Threads
- Copying of Files from an FTP server (Visual Basic 4 / 5 / 6)
- Access denied from files. (Windows NT / 2000 / XP)
- Copying multiple files with Visual Basic (Visual Basic 4 / 5 / 6)
- WD Drive-to-Drive not copying all files (Storage)
- Temporary Internet Files (Windows NT / 2000 / XP)
- Rather strange problem copying, need assistance. (Perl)
- Annoying problem with moving files (Windows NT / 2000 / XP)
- VMWare - transfer files - aaahh! please help (*nix Software)
Other Threads in the C++ Forum
- Previous Thread: C++ problem...
- Next Thread: How to use Dev C++
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






