Is there a way to replace any keyword in a text file using POSIX calls, without re creating the file..
If yes Please tell me how to do it..
Thanks in advance..
Well, I would start by bringing your code up to date. The .h's are used in C, but have been depricated in C++, and you also need to define your namespace (usually std for the general, but that's not 'best practice'). As well, your main should be int, not void, and this will require a return code at the end. After ...
i have wrote a client-server program in C. part of this program is dealing with users loggin in with ther id and passwrod. sever opens a file called 'passwords.txt' and ckecks to make sure id and password exist and ten it will send client a message to report successful login. (i've used fscanf to read from file and strcmp to compare) ...
Well I didn't read your code because you didn't use [code][/code] tags. But if you want to read the WHOLE file into memory, do all your editing and then write it back out again, I guess you could do that. But it is a dangerous way of solving the problem: - what happens if the file won't fit in memory. - ...
Think about the flow of the program, and work it through with paper and pencil first. Open the file, read the contents line by line with fgets(), until you reach the words to be replaced. All the lines are being written out to a second filename. Acquire the new word that you will be adding, and put it into the char ...