0

hallo
i want 2 know if there is a function that reads from an input file and after reading this char will disapear.
i mean the read char will b disappeared.

5
Contributors
10
Replies
11
Views
10 Years
Discussion Span
Last Post by Ancient Dragon
0

hallo
i want 2 know if there is a function that reads from an input file and after reading this char will disapear.
i mean the read char will b disappeared.

If not you could just write your own.

0

how i can read the file in memory
i want the char 2 b saved in memory not a copy

0

You have to copy everything after your character into an array or something, then come back and overwrite the character. Did you get me?

0

I think you need a clearer definition of what you want. characters don't just "disappear" -- unless your a magician.

Post an example of what you want. For example, if the word "hello" is read, do you want to delete the two 'l's and make it "heo"?

0

for ex:
here is my input file ack=100 , and i want 2 read the four chars ack= and then after reading the input file will b as shown 100

0

for ex:
here is my input file ack=100 , and i want 2 read the four chars ack= and then after reading the input file will b as shown 100

I don't no what you mean? :sad:
What is ack?

0

>then after reading the input file will b as shown 100
Files are persistent, they don't work like that. If you want a destructive read, you'll need to build it yourself by rewriting the file. Since that's an expensive operation, you'll want to seriously consider whether you really need this feature or not.

0

for ex:
here is my input file ack=100 , and i want 2 read the four chars ack= and then after reading the input file will b as shown 100

If I understand you, you want to put the value 100 into an integer variable:?: If that is true, you have a couple options:
(1) use sscanf(), or (2) pointer parsing. There are other options in c++ using stringstream class.

char buf[20];
int n;
// read a line into buf is not shown
//buf[] = "ack=100"; after read
//
sscanf(buf,"ack=%d",&n); // now n == 100

(2) parse with a pointer

char buf[20];
char* ptr;
int n;
// read a line into buf is not shown
//buf[] = "ack=100"; after read
//
ptr = strchr(buf,'='); // locate the '=' symbol
n = atoi(ptr+1); // convert remainder to int
This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.