📄 pex14_8.cpp
字号:
#include <iostream.h>
#include <ctype.h>
#pragma hdrstop
#include "ptf.h"
// for the n characters in s, translate each
// lowercase character to uppercase.
void UpperCase(char *s, int n)
{
while(n--)
{
if (islower(*s))
*s = toupper(*s);
s++;
}
}
void main(void)
{
PascalTextFile pfin, pfout;
char buffer[128];
int nchars;
// read from file "ptf.h"
pfin.Assign("ptf.h");
pfin.Reset();
// write to file "ptf.uc"
pfout.Assign("ptf.uc");
pfout.Rewrite();
// read "ptf.h", translate each lowercase character to
// upper case and write the modified characters to file "ptf.uc"
while(!pfin.EndFile())
{
// read up to 128 characters from pfin. assign the number
// actually read to nchars
nchars = pfin.PRead(buffer,128);
// if we are at end of file, break and exit
/*if (pfin.EndFile())
break;*/
// translate each lowercase character in buffer
// to upper case
UpperCase(buffer,nchars);
// write nchars characters to pfout
pfout.PWrite(buffer,nchars);
}
// close the two files
pfin.Close();
pfout.Close();
}
/*
<Run>
No run. List the file "ptf.uc".
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -