⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sinterp.cpp

📁 这是一些于C++做的经典例子
💻 CPP
字号:
#include "VM.H"


int main( int argc, char **argv )
{
  // The usage to this program is very simple:  it requires a single file name
  // which is the bytecode stream to execute.
  if ( argc != 2 ) {
    printf( "usage: %s file", argv[0] );
    return 1;
  }

  // Jump through hoops opening the file.  We need to know how big to allocate
  // the buffer, so make sure to seek to the end of the file to get its file
  // size.
  FILE *f = fopen( argv[1], "rb" );
  if ( f == NULL ) {
    perror( argv[1] );
    return 1;
  }

  fseek( f, 0, SEEK_END );
  size_t len = ftell( f );
  rewind( f );

  char *stream = new char [len];

  fread( stream, len, 1, f );

  // Now that we finially have the bytecode stream from the file, create an
  // instance of the VM and execute it.
  VM vm( stream, len );
  vm.Exec();

  delete [] stream;
  fclose( f );

  return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -