And one other small problem.
These two statements are wrong:
char write_buffer[4] = "abcd";
char read_buffer[4] = " ";
You need to allocate 5 bytes for 'a', 'b', 'c', 'd', \0
I don't know if your compiler ignores the 4 and allocates 5 instead, or if
it allocates only 4 and then doesn't terminate the string.
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Tuesday, July 25, 2000 11:20 AM
Subject: Re: File Streaming Problem
> In a message dated 7/25/00 11:24:51 AM Eastern Daylight Time,
> [EMAIL PROTECTED] writes:
>
> << Hi
> I want to use File Streaming API in my application. I have
> tried with FileWrite( ) and FileRead( ) calls. I am able to write some
> bytes into a file. But reading that file always returns zero objects.
> I didn't got any errors also. Can anybody suggest some way to do this.
>
> The code follows:
>
> int file(void)
> {
> FileHand tmpFile = NULL;
> Int32 written, read;
> char write_buffer[4] = "abcd";
> char read_buffer[4] = " ";
> tmpFile = FileOpen (0, "ptt1.txt", 0, 0, fileModeReadWrite, NULL);
> if (tmpFile == NULL)
> {
> printf("Error opening file");
> }
>
> written = FileWrite (tmpFile, (void *)write_buffer, 1, 4, &err);
> printf("Bytes Written = %d.\n",(int)written);
>
> read = FileRead (tmpFile, (void *)read_buffer, 1, 4, &err);
> printf("Bytes Read = %d.\n",(int)read);
> err = FileClose(tiffFile);
> return 0;
> }
> debugging returns err = 0
>
> Thanks in advance
>
> venkatesh >>
>
> Just as an offhand observation of your function: if you are trying to read
> the same bytes that you just wrote then you're going to want to set the
file
> pointer back to the beginning of the file. Otherwise, you will be
attempting
> to read bytes from the end of the file, in which case you would be getting
> the read problem that you describe. There's probably a FileSeek()
function
> that you can use to reset the file pointer to anywhere that you desire
> (BEGINNING, CURRENT, END).
> Hope this helps, -Pete
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/