| | |
How to clear the character in the file???
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
I was creating some sort of text editing program.
Whose display and file writing are going parallely.
How to clear the character in the file when i dont back space.
I tried clear character by replacing with Space(32), NULL(0), but it didn't workout fine.. just replacing the character...how do delete the character.
Whose display and file writing are going parallely.
How to clear the character in the file when i dont back space.
I tried clear character by replacing with Space(32), NULL(0), but it didn't workout fine.. just replacing the character...how do delete the character.
c Syntax (Toggle Plain Text)
//i tried it like this fseek(fp,-1,SEEK_CUR); fputc(<character to be replaced>,fp); fseek(fp,-1,SEEK_CUR);
Chazing Dreams ;'P
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
•
•
•
•
Usually you change the buffer in memory, then write the whole buffer to the file after all the changes are made. Don't try changing the file as you change the display.
I tried in many ways but eg. spaces (32), NULL(0) but its is also one of the character.
eg.
"this is the file <space><space><space><eof>" which should be
"this is the file<eof>" cosidering that i did backspacing from last only.Please help!
Chazing Dreams ;'P
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
No you can't do that.
Some platforms provide a specific "truncate" function to allow you to make a file shorter by removing stuff from the end.
But there is no API which allows you to turn say
hello world
into
goodbye world
in such a way that the file will automatically make room for the extra data.
In short, you have to rewrite the entire file from scratch each time.
Replacing text with other text which is the same length is possible, eg
hello world
into
howdy world
Indeed, this is how files with fixed-length records typically work.
Some platforms provide a specific "truncate" function to allow you to make a file shorter by removing stuff from the end.
But there is no API which allows you to turn say
hello world
into
goodbye world
in such a way that the file will automatically make room for the extra data.
In short, you have to rewrite the entire file from scratch each time.
Replacing text with other text which is the same length is possible, eg
hello world
into
howdy world
Indeed, this is how files with fixed-length records typically work.
•
•
•
•
No you can't do that.
Some platforms provide a specific "truncate" function to allow you to make a file shorter by removing stuff from the end.
But there is no API which allows you to turn say
hello world
into
goodbye world
in such a way that the file will automatically make room for the extra data.
In short, you have to rewrite the entire file from scratch each time.
Replacing text with other text which is the same length is possible, eg
hello world
into
howdy world
Indeed, this is how files with fixed-length records typically work.
i understand what you are saying and i am trying to write solve same problem which you mention making of "hello world" to "how is world".
But thats not what i want.. I want to know how to clear the character form the buffer.. at least from back side, so that it doesn't show something like
"text<NULL>........<NULL><EOF>"
i guesss you under stand..
just deleting...
i don't know ... please help me out..
Last edited by Rhohitman; Jan 24th, 2009 at 11:52 am.
Chazing Dreams ;'P
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
•
•
Join Date: May 2008
Posts: 570
Reputation:
Solved Threads: 93
We're having a communication problem.
We are recommending that you create in memory a copy of what you want the file to contain. You are being specifically advised against trying to 'edit' the file as the user types keys.
The memory 'buffer' is what the user will edit. They can append to it, delete, whatever. (if you're having problems with editing in the buffer, ask about that.)
Once you have the buffer that is what should be in the file, you open the file, write the buffer and close the file.
If you're looking to make sure the file on disk is close to the buffer in memory, you could look into a periodic 'auto-save' of the file. (You could auto-save to the actual output file, but you should probably let the user know. Normally user files are only written on user command. Alternatively you could auto-save to a slightly different name -- like outputfile.asv or some other transformation of the real output name.)
We are recommending that you create in memory a copy of what you want the file to contain. You are being specifically advised against trying to 'edit' the file as the user types keys.
The memory 'buffer' is what the user will edit. They can append to it, delete, whatever. (if you're having problems with editing in the buffer, ask about that.)
Once you have the buffer that is what should be in the file, you open the file, write the buffer and close the file.
If you're looking to make sure the file on disk is close to the buffer in memory, you could look into a periodic 'auto-save' of the file. (You could auto-save to the actual output file, but you should probably let the user know. Normally user files are only written on user command. Alternatively you could auto-save to a slightly different name -- like outputfile.asv or some other transformation of the real output name.)
![]() |
Similar Threads
- help me to read my data file:(( (C)
- Scanning a text file for a string (C++)
- Trying to creating an array from a text file (C++)
- write to text file using fprintf() (C)
- File Processing C++ (C++)
- code seems to stop executing (C++)
- I've got Trojan.Holax... is this bad? (Viruses, Spyware and other Nasties)
- not-a-virusadware (Viruses, Spyware and other Nasties)
- CPU and RAM always in a really high capacity (Viruses, Spyware and other Nasties)
- reading a file into code (Java)
Other Threads in the C Forum
- Previous Thread: Preventing code from using code
- Next Thread: about file handling
| Thread Tools | Search this Thread |
#include adobe ansi api append array arrays asterisks binarysearch changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc csyntax database directory dynamic execv feet fgets file fork framework frequency function getlasterror givemetehcodez global grade gtkgcurlcompiling hacking hardware highest histogram include incrementoperators infiniteloop input interest kernel keyboard kilometer license linked linkedlist linux linuxsegmentationfault list lists locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft motherboard mqqueue number odf opensource overwrite owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing scripting segmentationfault sequential socket socketprograming standard string systemcall testing threads turboc unix user voidmain() wab windows.h windowsapi






