I having a strange problem when I try and read out of a file, and then write back into it.
In one function, I'm reading it using:
Code:
FILE *fp = fopen(args[1],r);
and then using x = fgetc
but later on in another function I'm doing
Code:
FILE *fp1 = fopen(args[1],w);
and then writing to it
These file pointers are in seperate functions and neither one of them gets passed to the other function.
The problem is when I try to run it, it crashes, and the only way to solve the problem is to then change both the 'r' and 'w' to 'rw'
For some reason this then means that I can't seem to write to the file at all.
It's acting very strange, especially as the operations are done in seperate functions. It doesn't seem to like me having different file permissions from seperate pointers.
Can anyone give me any ideas as to how this sort of issue is resolved, or where I'm likely to be going wrong?
Thanks