|
Does anyone know how to overwrite / delete a particular line of data from a file?
eg.
First, First <--- Line 1
Second, Second <--- Line 2
Third, Third <--- Line 3
If I would like to overwrite / delete Line 2 how should I go about retriving the particular line and overwrite or delete it ?
Thanks in advance
|
|
|
|
|
Well, file manipulation is buffer manipulation.
You will have to rewrite the file. Any editor does it that way: load the file, manipulate it, write it to disk again. Some editors (saving physical memory) write to a temporary file first, delete the old and rename the new file.
As I am not that familiar with (V)C++, I would suggest
fgets to retrieve the lines. Then store them in a linked list and manipulate that list until it meets your requirements. Then write it back to disk.
Open file (read-only)
begin loop
Read line from file
store line (linked list, dynamic array... whatever you can do)
loop until eof
close file
manipulate list
open file (same file, do not append data but overwrite instead)
begin loop
write line to file from list
delete line from list
loop until last element
close file
Thats what I would do
Cheers
Sebastian
|
|
|
|
|
If you want to delete a line(or anything else) from a file
you must rewrite the hole file.
I would write in another file(temporary), then delete the initial file, and then rename the temporary file with the
name of initial file.
But, If you want to overwrite data in a binary file, you
must open the file with write acces, then go to the begining of data you want to overwrite and then write
the new data (the size of the new data must be the same
as the size of the old data).
If you want an easy C++ class that uses Win32 API file access functions for creating,reading and writing binary
files send me an e-mail.;)
iCounter
|
|
|
|
|
Is Visual C++.Net ANSI C compliant?
|
|
|
|
|
The short answer is no, but 7.1 is very close.
What they are missing out on is relatively minor at the moment - specifically separate compilation of templates using export. Probably a better question to ask is 'is there another compiler out there better?', and there are some. Intel's compiler is an optimizing compiler, and comeau seems to travel ahead of the pack feature wise. Some of the major compilers are compared in the boost regression tests , although this isn't an entirely fair comparison because of compiler based configuration files and developer mistakes it gives a rough indication of how compilers perform in real world situations.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Yes, but it allows a lot of extensions. Compile with the /TC (Compile as C) and /Za (Disable Language Extensions) options to ensure that you're compiling as C rather than C++, and only using ANSI features.
(The other poster is talking about C++ conformance, which is a different thing.)
|
|
|
|
|
Hi all,
I've written a small program and I want to be able to run it on many machines by carrying the executable around on a floppy. However, when I try to run it on another machine I get an error saying that MSVCP60D.dll can't be found. Is there a way to link that dll so that the entire program is in the exe so I only need to copy 1 file?
Thanks in advance.
|
|
|
|
|
|
I am porting a XML based project from VC6.0 to VC7.0. But, 7.0 compiler shows 'ambigous symbol' error. How can I solve it.
|
|
|
|
|
You're not helping much. What is ambiguous?
Normally this is down to having a symbol clash inside and outside a namespace, one of the favourite culprits being InlineIsEqualGUID.
Steve S
|
|
|
|
|
When I include
#import "msxml3.dll"
using namespace MSXML2;
in the header file, some of the Interface Pointer Declarations are clashing. But when I specify the namespace locally, its accepting.
|
|
|
|
|
Try not importing MSXML3, but instead, #include msxml.h or msxml2.h
You'll only have raw interfaces that way, but it should eliminate the namespace problems.
Alternatively, don't have 'using namespace', and specify it locally.
It's a pain, but hey, that's life...
Steve S
|
|
|
|
|
In VC6.0, how to programme to encode CDA (CD audio track) to WMA?
Hint is ok!
Thanks!!!
Rap off for you,for me,for our human.
|
|
|
|
|
|
I do believe thats a bit of an overkill.
Simply klick the "Record Button" in the MS Windows Media Player, which will rip any Audio CD to Harddisk.
To the threadstarter:
If you did mean: How do I encode the .cda files which Explorer is showing when viewing a Audio-CD: They are no actual files. They are more like "links" to the actual Audio Data, to enable Programs to play Audio Tracks by klicking on that track in the explorer.
Cheers
Sebastian
|
|
|
|
|
hello..
has anyone tried using adobe acrobat sdk. plz tell me how to use the sdk. though the documentation is provided, non of the sample code provided is functioning properly.
please help me...
thanks in advance
|
|
|
|
|
mohdshiraz wrote:
...non of the sample code provided is functioning properly.
Have you tried posing this same question to one of the Adobe forums?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
NO.. but i did search every where on the net..any help ?
|
|
|
|
|
mohdshiraz wrote:
any help ?
http://www.adobeforums.com/cgi-bin/webx?14@@.eed56a0
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
I am trying to automate Outlook using Visual C++. Here is what I am trying to do:
void CTestOutlookDoc::OnFileTest()
{
Outlook::CApplication pApp;
if (!pApp.CreateDispatch(_T("Outlook.Application")))
{
CString str;
str.Format("CreateDispatch() failed w/error 0x%08lx", e.m_sc);
AfxMessageBox(str, MB_SETFOREGROUND);
return;
}
pApp.m_bAutoRelease = TRUE;
pApp.Quit();
return;
}
When the code is executed, an instance of Outlook is created. However, even I call Quit() in my code, OUTLOOK.EXE still remains in Windows Task Manager after the program is quit. What should I do in order to kill the OUTLOOK process when I call Quit() in my function?
Regards,
Frank
|
|
|
|
|
I am a domain administrator for a Win 2K system. My domain a/c is included in the administrators list. Though I have these privileges, I am not able to register any dll. But I can register dll as a local admin. Is there any changes tobe done, so that I can registe Dlls from the domain A/C.
Shenthil
|
|
|
|
|
|
Hi, Friends,
I developed a shareware to protect and manage passwords, which has following features:
1. USB-Disk and Floppy disk supported
2. MD5 Algorithm supported to store User account info
3. Industrial-Standard Encryption Algoritm to protect password items
4. Bird-Eye (C) Technology adopted to prevent peering
5. Hacker Hooking prevented
Welcome evaluate it from http://www.annexsoft.com/kingpass/index.htm
and send any comments to me (relations@annexsoft.com).
//***************************
I believe ideal is not always so far away...
|
|
|
|
|
Idea number one - if you want to advertise your products, run an add, they appear on the left. If you want people to evaluate your code, post your code.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Nicely said, Christian.
Heard in Bullhead City - "You haven't lost your girl - you've just lost your turn..." [sigh] So true...
|
|
|
|