A
Arquitecto
Hi ,
I have a question about a file operation i want to do . I have a data
file lets say X bytes . I want to read the file and delete a byte
every 2nd byte . I am a little comfused ,my approach is like this .
main()
{
char buf[1024];
FILE *fp;
fp=fopen("data", "rb");
while(!feof(fp)) {
fread(buf, 1, 1, fp);
}
fclose(fp);
}
ok ,with this i can read 1 byte at a time till end .Now what i want to
do is .... i want to have on buf the 1 byte ,3rd byte .. 5th .. etc
and discard 2nd .. 4th ...etc .My thought was to take the position of
the file pointer ,
example : position= ftell(fp) and if position % 2 == 0 then do not
read ..
but i dont know if i am on right way or is a correct way to do what i
want .I will appreciate comments on how to approach it . thanks in
advance .
I have a question about a file operation i want to do . I have a data
file lets say X bytes . I want to read the file and delete a byte
every 2nd byte . I am a little comfused ,my approach is like this .
main()
{
char buf[1024];
FILE *fp;
fp=fopen("data", "rb");
while(!feof(fp)) {
fread(buf, 1, 1, fp);
}
fclose(fp);
}
ok ,with this i can read 1 byte at a time till end .Now what i want to
do is .... i want to have on buf the 1 byte ,3rd byte .. 5th .. etc
and discard 2nd .. 4th ...etc .My thought was to take the position of
the file pointer ,
example : position= ftell(fp) and if position % 2 == 0 then do not
read ..
but i dont know if i am on right way or is a correct way to do what i
want .I will appreciate comments on how to approach it . thanks in
advance .