|
I use fopen(fp, "r+") to update the file
I find the key which I want to update (with fgets())
now i print with fprintf("%s\n"),
It just override the old text,
but not open new line.
RutR
|
|
|
|
|
You can't. The only way to do it is open a temporary file, copy up to the line you wish to add, copy the new line, then copy the rest of the file. Then, delete the original file and rename the new one with the original name.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
It's a suggestion to provide you one more option about what you can do .Take the contents of a file (if the size is small )and put it in a buffer. Create some space by shifting the buffer with the length of your string. Copy your string to the emptied space and then save it to the file
Otherwise you will have to proceed the way Cedric suggested
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I need some help with debugging in VS8. I've got a vector of pointers, and at some point during runtime my vector goes null (which I need it not to do). I'd like to be able to break in the code as soon as that vector variable changes so I can figure out where it's being cleared. Is there a way to tell the compiler to break when a variable's value has changed? I cannot fully trace the call stack because the code is being called through COM (this is from a C# GUI to unmanaged C++ code). Any help would be appreciated. Thanks.
|
|
|
|
|
Look up 'data breakpoints' in the help.
Data breakpoints allow you to break execution when the value stored at a specified memory location changes.
You can set data breakpoints in break mode only.
Addresses of variables change from one debugging session to the next. For this reason, data breakpoints are automatically disabled at the end of each debugging session. If you attach a data breakpoint to a local variable, the data breakpoint remains enabled when the function ends. The memory address it is attached to no longer has the same meaning, however, so the results of such a breakpoint are unpredictable. If you set a data breakpoint on a local variable, it is best to remove or disable it before the function ends.
Visual Studio currently supports setting four data breakpoints per project.
How to Set a Memory Change Breakpoint
1. From the Debug Menu, choose New Breakpoint and click New Data Breakpoint
—or—
in the Breakpoints window Menu, click the New dropdown and choose New Data Breakpoint.
The New Breakpoint dialog box appears.
2.In the Address box, enter a memory address or expression that evaluates to a memory address. For example, &foo to break when the contents of variable foo change.
3.In the Byte Count box, enter the number of bytes you want the debugger to watch. For example, if you enter 4, the debugger will watch the four bytes starting at &foo and break if any of those bytes change value.
4.Click OK.
--
The Obliterator
|
|
|
|
|
You are going to need to break when the memory changes. Based on your description, my suspiscion is that something is writing to memory it doesn't own.
Do you have a pointer to the vector of pointers, or is this the actual object and its data element (the array of pointers) is going null at some point?
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hello everyone,
I heard that page based I/O can improve performance, so some guys developed some page based I/O library which reads a file in page unit. For example, when we read the first byte, they will read an entire page (for example, 4k bytes) into memory, then when we are seeking to some other bytes inside a page, the bytes can be found from the page loaded in memory.
But, I also heard that when accessing OS File I/O, OS File I/O library implements page based I/O internally, for example, when you just read a byte using fseek or something, it will reads a whole page (maybe 4k or something) into memory.
My question is, which is true (OS provides page based I/O internally or not)? If OS provides page based I/O, why some guys always say that they are using page based I/O to improve performance.
thanks in advance,
George
|
|
|
|
|
This is one of those times where the code in question has been written and refined over many, many years. Improving hard drive access times is something that's always being improved. Let the OS and the hard drive do the cacheing for you.
If you want more details, search Channel9 for the interview with Molly Brown - she talks a lot about kernel mode memory and she discussed cacheing.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Thank you Michael!
Do you mean OS have already provide page based buffer functions?
regards,
George
|
|
|
|
|
In general, reading files in multiples of the disc sector size will offer a slight speed improvement. In the real world, an application has to be very disc bound to notice the difference since most hard drives and the OS itself do caching.
My own experience is that for streaming data, reading/writing files in multiples of the sector and page size, usually 32k chunks, offers the best performance.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hi Joe,
Do you mean OS File system API does not provide page based buffer function internally and we have to read chunk by chunk (for example, 32k) by ourselves?
regards,
George
|
|
|
|
|
When you do a standard read the OS file system may or may not buffer the file data. It does so, however, at a very granular level. If you are streaming in and out large quantities of data, you can improve the performance by controlling this yourself. You can go even further and instruct the OS to not attempt any sort of caching, though you must ensure your buffers match the sector size of the hard disc.
I am speaking entirely in generalities. You will have to make the determination of how to handle your file data based on the requirements of your program. If speed is extremely important, you should try and benchmark different algorithms.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
So, the answer is "it depends" right? I am wondering whether there are any related resources (tutorials, ...) that I can make a reference about this topic. Any recommendations?
regards,
George
|
|
|
|
|
Hi
I have a property sheet with tabbed property pages
When the property sheet is opened up, depending on some user settings some pages
are not displayed
When the property sheet is created, i add all the pages
the in OnInitDaig, i remove the pages i dont need with
RemovePage(&m_Page1);
this works fine, if i only open the sheet up once
If i try to open again, i get an expection error on RemovePage line
anyone any ideas
thanks
si
|
|
|
|
|
si_69 wrote: If i try to open again, i get an expection error on RemovePage line
this is because you trying to remove the page which doesn't exist at all!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
How load a bitmap from bmp file at run time
|
|
|
|
|
::LoadBitmap and optional CBitmap::FromHandle can help.
|
|
|
|
|
Viorel. wrote: ::LoadBitmap and optional CBitmap::FromHandle can help.
you can't load Image from File using these function!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
You are right. The image can be loaded from separate file using ::LoadImage function with LR_LOADFROMFILE flag, as was answered by sujtha.
|
|
|
|
|
but LoadBitmap(bitmap resource);not file
whitesky
|
|
|
|
|
You are right. The image can be loaded from separate file using ::LoadImage function with LR_LOADFROMFILE flag, as was answered by sujtha.
|
|
|
|
|
Viorel. wrote: You are right. The image can be loaded from separate file using ::LoadImage function with LR_LOADFROMFILE flag, as was answered by sujtha.
Isn't i answered before Ms Sujtha ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
ThatsAlok wrote: Isn't i answered before Ms Sujtha ?
Yes, I missed your message, sorry.
|
|
|
|
|
WhiteSky wrote: ut LoadBitmap(bitmap resource);not file
After long time i win the Leg Race
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi ThatsAlok, how are you,you are absent here !?
i think now you are very fast man not me and one thing where i write ut i write but
whitesky
|
|
|
|