Hi all:
does anyone know how to make a simple function that searches for a particular word in a file? So more words could be inserted at that point of the file?
Is there anyway to do that?
Thanks in advance!
Hi all:
does anyone know how to make a simple function that searches for a particular word in a file? So more words could be inserted at that point of the file?
Is there anyway to do that?
Thanks in advance!
There is no simple way to "insert", or delete for that matter, from the middle of a file. Basicly it comes down to running through the file until you find what you want, copying everything to that point some place, doing your insertion (or deletion, but that takes a slight adjustment on your initial copying, case specific), and then copying the rest of the file over. Try it, it's a good exercise.
Quzah.
Hope is the first step on the road to disappointment.
Can anyone make sample code of that ( the above)? ^
I think you should quickly edit that last comment from your post....
Make an effort. Think of what quzah suggested and try to think of exactly what you need to do. Split the problem up into simple tasks. eg:
1. I need to read from a file.
2. I have to make changes to a specific part of a file.
3. I need to write back to a file.
Post your code after you've made an honest effort. Nobody is here to help do homework, but we are here to help guide you.
it's not for homework, you dumbASS!!!!
it's just a "sample code" to guide me.....
p.s. wat a jackass! maybe his fatass's too big and got stuck in a toilet...
Last edited by muk_luk; 03-24-2004 at 08:56 PM.
>it's not for homework, you dumbASS!!!!
Then you shouldn't have any problem doing it. We have a high tolerance for ignorance when it comes to students because many teachers are of such poor quality. If this is a real job, or you are teaching yourself then you should know how to begin going about it (for the former) or have enough interest to do research (for the latter).
>it's just a "sample code" to guide me.....
Right. Well, if you can't read a file and then use strstr you need more "guiding" than we can offer.
>p.s. wat a jackass! maybe his fatass's too big and got stuck in a toilet...
Pointless flames only make you look like a fool. You're post is reported by the way, the mods will be keeping an eye on you.
My best code is written with the delete key.
>>the mods will be keeping an eye on you.
Speak of the devil...
muk_luk: You're not going to make any friends with that kind of attitude. Quzah expressed your options correctly, and OOPboredom is correct in indicating that you will get much farther here after you've made some kind of attempt on your own. Anything at all.
I'll give you a pointer in the right direction. Look up fopen and fread/fwrite for an idea on how to open and read/write from/to a file.
Prelude alreaded pointed you to strstr as a way to parse the data you get from your file. Play with it a bit and come back with whatever you get.
Good luck (and please, no more flames). Thank you.
"There's always another way"
-lightatdawn (lightatdawn.cprogramming.com)
This board offers help to those who want to learn. If you are unwilling to learn, please don't flame people.
We don't offer complete solutions though we could. There is a simple reason for it: offering complete solutions will teach next to nothing. It will only teach people to come back and expect another complete solution for a problem. We are here to teach, not to provide complete solutions. Some of us do that for a living already.
If you have tried the above suggestions and have problems with your code or concept, feel free to open up another thread including the part of code you think is the problem. This thread will probably not get you any constructive answers anymore, the people who post here are volunteers, they don't have to help you, so you better make friends not enemies.
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.
what I was originally intend to do was to simply ask for a piece of sample code so I know what Quah was talking about... (maybe a few lines will do)..
but some jackass has this problem with typing out a few lines of code for others, thinking he's all good with programming and others ask FOR CODE ONLY BECAUSE THEY ARE DOING HOMEWORK. Well, for his information, SOME PEOPLE DO ACTUALLY WANT TO LEARN ON THEIR OWN.
Cheers if you want to help..for the rest who don't, go Mod Edit youself!
Thread closed due to attitude problems of last poster.
I frankly dont care what the issue is in this case, we dont welcome that kind of abuse here
Sorry Fordy, just wanted to add, rule 3 discusses bad language and specifically mentions "starring out" letters. If I see it again, you'll get a formal warning.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.