When I Write Binary File. i had some problem 
Author Message
 When I Write Binary File. i had some problem

hi every one
i'm korean, because my english expression is poor

i write binary file
the source code is below
//--------------------------------------
#include <stdio.h>
#include <io.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <memory.h>

int main( )
{
   char l_bbbuf[ 10 ];
   memset( l_bbbuf, 0x0d, sizeof( l_bbbuf ) );

   FILE* l_hFile;
   l_hFile = fopen( "test.dat", "wb" );

   for( int i = 0; i < 10 ; i++ )
        fputc( l_bbbuf[i], l_hFile );

   fclose( l_hFile );

Quote:
}

//------------------------------------------------
this is all. i want write 0x0d in file
after this program run, i open the "test.dat" and show hex
viewer the data.
that is 0x0d 0x0a 0x0d 0x0a......0x0a

i don't want write 0x0a..

what is the problem?

please help me...

sorry my english expression is so poor



Mon, 25 Jul 2005 15:00:19 GMT  
 When I Write Binary File. i had some problem


Quote:
> hi every one
> i'm korean, because my english expression is poor

> i write binary file
> the source code is below
> //--------------------------------------
> #include <stdio.h>
> #include <io.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <memory.h>

> int main( )
> {
>    char l_bbbuf[ 10 ];
>    memset( l_bbbuf, 0x0d, sizeof( l_bbbuf ) );

>    FILE* l_hFile;
>    l_hFile = fopen( "test.dat", "wb" );

>    for( int i = 0; i < 10 ; i++ )
>    fputc( l_bbbuf[i], l_hFile );

>    fclose( l_hFile );
> }
> //------------------------------------------------
> this is all. i want write 0x0d in file
> after this program run, i open the "test.dat" and show hex
> viewer the data.
> that is 0x0d 0x0a 0x0d 0x0a......0x0a

You must be running some other version of
your program than what is produced by the
above code.  When I paste the above code
into a .cpp file and compile and run it,
I get the following hex dump of test.dat:
0000 0000 0D 0D 0D 0D 0D 0D 0D 0D  0D 0D

Quote:
> sorry my english expression is so poor

It's good enough.

--
-Larry Brasfield
(address munged, s/sn/h/ to reply)



Mon, 25 Jul 2005 15:17:18 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. problems writing to binary files

2. having problem with this code for hex/binary conversion

3. Binary file I/O using ofstream::write() blows away remaining data to end of file

4. Having problems incorporating pre-written code into my program

5. Having problems incorporating pre-written code into my program

6. CEdit::CharFromPos -- trying to write a bugfix, please help (having problems with tabs)

7. Having a problem in writing a service Application

8. reading and writing to binary files

9. Reading and Writing Ascii and Binary Files

10. write at a certain position in a binary file

11. Copying Over Elements Already Written to a binary File - mytest.cpp (0/1)

12. Help with writing to binary file through functions

 

 
Powered by phpBB® Forum Software