I am working on a program to manipulate files. Data is read
from input file and is to be transposed into the output file.
Here is the description :
Input File
^A^@^U^G^L^G^Q^G^F^h
^H^P^a^j^i^k^l^m^f^x
and multiple lines like this. Specs. indicate each line can
be upto 32MB!!!.
I am printing the decimal equivalent of these characters in the
output file. Output has to be like :
/* I have copied input chars. to illustrate. In reality output file
has decimal equivalents of input chars. */
^A^H
^@^P
^U^a
^G^j
^L^i
^G^k
^Q^l
^G^m
^F^f
^h^x
and so on.
What I have done is to read each line into a 'unsigned char buffer'. Find the length of the buffer, print each character
of the buffer, add a newline and advance file pointer.
fp1 = Output file pointer
length = Length of input buffer(line)
buf = unsigned char buffer
/** Snippet of code **/
for(index = 0 ; index < length ; index++)
{
pos = ftell(fp1) ;
fprintf(fp1,"%d",buf[index]);
fprintf(fp1,"\n");
pos = ftell(fp1) ;
fseek(fp1,pos+(length/2)-1,SEEK_SET);
}
iteration+= 1 ; /* Moves the fp1 to beginnig of 2nd col. */
fseek(fp1,iteration,SEEK_SET);
/********************/
This does print the data as I want it. But it also adds extra
characters to the output file(I believe newline). I do not want
that. Is there is a way it can be accomplished without adding
'extra/new' characters in the output file.
PS : The input files can be very huge, as they are generated by
a automatic chip tester. Each line can be upto 32MB !!!.So far
I have worked on only simple file stuff.
Any inputs are really appreciated.
Thanks in advance.