Random File Access for writing

Hi everybody,
I need to use random file access for reading and writing in C language only.
For reading i have implemented the logic and its working fine.
For writing , i am not getting the idea. :(
Please help me out.
below is All brief discussion :-
File Creation :-

1. create 2 files name : "FileId.txt" and "FileData.txt" .
2. FileData.txt :

"Enter ID"
"Enter Password"
"Wrong Password"
"Activation"


3. open "FileData.txt" file read each line one by one and calculate length of each line.
and write it 4 byte format in "FileId.txt" file.
4. FileId.txt:
0000 0014 0014 0021 0035 0024 0059 0025...

Start Pos and length of parameter.

File Reading :-

1.Open File "FileId.txt" and on basis of screen Enum value read that parameter value(enum*8) .


For Config File

File Creation :-

1. create 2 files name : "ConfigID" and "ConfigData" .
2. ConfigData:
#TERIP=111.222.333.444
#TIMEOUT=60
#PORT=1234
#TID=7678687
#MID=6687688

3. open "ConfigData" file read each line one by one and calculate length of each line.
and write 8 bytes in 4 byte format in "ConfigID" file.
4. ConfigID:
0000 0014 0014 0021 0035 0024 0059 0025...

Start Pos and length of parameter.

File Reading :-

1.Open File "ConfigData" and on basis of parameter Enum value read that parameter value(enum*8) .

File Writing :-
1. Open File "ConfigID" and basis of enum value read eight character value.
2. Open file "ConfigData" if the data , which we are going to write in the file is equal to the target data.just write the data and close the file.
if source data is less then pad the data with spaces then write to the file.
if source data is more then ? (Thats the real issue????)

Thanks in advance .
Andy
Last edited on
Have you written any code?
Hi,
I have written code for reading only and that's working fine.
please suggest me something ...
Is the problem in growing the file? If it is, you could write zeros or something top pad the file out the the size you want, then write your data.

If not, can you please explain what is the problem.
Topic archived. No new replies allowed.