原创 __int64 printf需要用%I64d

2012-1-18 16:31 3843 7 7 分类: 软件与OS

/* FGETPOS.C: This program opens a file and reads
 * bytes at several different locations.
 */

#include

void main( void )
{
   FILE   *stream;
   fpos_t pos;
   char   buffer[20];

   memset(buffer,0, 20*sizeof(char));

   if( (stream = fopen( "fgetpos.c", "rb" )) == NULL )
      printf( "Trouble opening file\n" );
   else
   {
      /* Read some data and then check the position. */
      fread( buffer, sizeof( char ), 10, stream );
      if( fgetpos( stream, &pos ) != 0 )
         perror( "fgetpos error" );
      else
      {
         fread( buffer, sizeof( char ), 10, stream );
         printf( "10 bytes at byte %I64d %s\n",pos,buffer );
  // printf("%s", buffer);
      }

   /* Set a new position and read more data */
   pos = 140;
   if( fsetpos( stream, &pos ) != 0 )
      perror( "fsetpos error" );

   fread( buffer, sizeof( char ), 10, stream );
   printf( "10 bytes at byte %I64d: %s\n", pos, buffer );
   //printf("%s",buffer);
   fclose( stream );
   }
}

 

 

PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
7
关闭 站长推荐上一条 /3 下一条