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

📄 ex4.cpp

📁 本程序用来模拟虚拟页式存储管理中的页面置换 & $ 快表页面固定为4块
💻 CPP
字号:
// Borland C++ - (C) Copyright 1991 by Borland International

// ex4.cpp:   Default arguments and Pass-by-reference
// from Hands-on C++
#include <iostream.h>
#include <ctype.h>

int get_word(char *, int &, int start = 0);

main()
{
   int word_len;
   char *s = "  These words will be printed one-per-line  ";

   int word_idx = get_word(s,word_len);           // line 13
   while (word_len > 0)
   {
      cout.write(s+word_idx, word_len);
                cout << "\n";
      //cout << form("%.*s\n",word_len,s+word_idx);
      word_idx = get_word(s,word_len,word_idx+word_len);
   }
   return 0;
}

int get_word(char *s, int& size, int start)
{
   // Skip initial whitespace
   for (int i = start; isspace(s[i]); ++i);
   int start_of_word = i;

   // Traverse word
   while (s[i] != '\0' && !isspace(s[i]))
      ++i;
   size = i - start_of_word;
   return start_of_word;
}

⌨️ 快捷键说明

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