|
void writeb( void )
{
FILE *stream;
char list[30],lista[30];
int i, numread, numwritten;
/* Open file in text mode: */
if( (stream = fopen( "host:d:/temp/tstf/a.txt", "w+b" )) != NULL )
{
for ( i = 0; i < 25; i++ )
list = (char)('z' - i);
/* Write 25 characters to stream */
numwritten = fwrite( list, sizeof( char ), 25, stream );
printf( "Wrote %d items\n", numwritten );
fclose( stream );
}
else
printf( "Problem opening the file\n" );
if( (stream = fopen( "host:d:/temp/tstf/a.txt", "r+b" )) != NULL )
{
/* Attempt to read in 25 characters */
numread = fread( lista, sizeof( char ), 25, stream );
printf( "Number of items read = %d\n", numread );
printf( "Contents of buffer = %.25s\n", lista );
fclose( stream );
}
else
printf( "File could not be opened\n" );
}
将程序下到vxsim里面,shell运行writeb,显示写文件25个字节成功,写完后再fopen for read 也成功,但是没有读回数据;在指定位置也没有找到创建的文件。。
请问是怎么回事?
|
|