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

📄 pex8_3.cpp

📁 数据结构C++代码,经典代码,受益多多,希望大家多多支持
💻 CPP
字号:
#include <iostream.h>
#include <iomanip.h>
#pragma hdrstop

#include "wex8_7.h"

int CapLine(ReadFile& f, char *capline)
{
	char *p = capline;
	
	// read a line from f. if at end of file, return False
	if (f.Read() == 0)
		return 0;

	// copy line just read to capline
	f.CopyBuffer(capline);

	// capitalize the string
	while(*p != NULL)
	{
		if ('a' <= *p && *p <= 'z')
			*p -= ' ';
		p++;
	}
	
	// return True
	return 1;
}

void main (void)
{
	char fname[30], line[80];

	cout << "Enter the file name: ";
	cin >> fname;
	cout << endl;
	
	// declare an ReadFile object that reads fname and has a
	// 80 character buffer
	ReadFile f(fname,80);

	// read the file and capitalize its lines
	while (CapLine(f, line) != 0)
		cout << line << endl;
}
/*
<Run>

<file "pex8_3.dat>

This text file tests the
construction of the class ReadFile
in Written Exercise 8.7

Enter the file name: pex8_3.dat

THIS TEXT FILE TESTS THE
CONSTRUCTION OF THE CLASS READFILE
IN WRITTEN EXERCISE 8.7
*/

⌨️ 快捷键说明

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