visual studio - How To read/write C array stored in text file created through bin2C utility -
i creating application, input c file having array ( created bin2c.exe ) , code segment of c file is:-
unsigned int myarray[] = { 0x00000001,0x00000002,0x00000005 ...};
now need read array text file , story value in int array. need modify array , put text file final output like:-
unsigned int myarray[] = { 0x39481212,0x33943121,0x3941212 ...};
please let me know how can in c/visualc++ application in vc++ mfc?
regards, vikas
input
open file (fopen
) in text mode , read lines (fgets
, sscanf
)
store array
you cannot have array unspecified size. must either use size limit , leave elements unused, or use malloc
, friends , manage storage array manually
modify
use +
, -
, *
, other operators along sqrt
, abs
, sin
, other functions available in standard library massage data (you can create functions of own too)
put back
it's better write new file , if went ok, delete old file , rename new 1 ... open new file (fopen
"w" mode parameter) @ beginning when opening input; if input not array line write (fputs
) directly, otherwise write 'massaged' line; read , write other lines.
(c++?) mfc
the above c
. might work c++
or without mfc
regards
have fun!
Comments
Post a Comment