?? c58.cpp
字號:
// c58.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
void Out();
void InWord();
void InLine();
void InChar();
int main(int argc, char* argv[])
{
Out();
InWord();
InLine();
InChar();
return 0;
}
void Out()
{
ofstream outFile( "text.txt" );
if ( !outFile )
{
cout << "error opening text.txt\n";
exit(1);
}
outFile << "How are you!\n";
outFile << "Find.\n";
}
void InWord()
{
ifstream inFile( "text.txt" );
if ( !inFile )
{
cout << "error opening text.txt\n";
exit(1);
}
char one[64] = "";
cout << "以單詞形式顯示:\n";
while ( !inFile.eof() )
{
inFile >> one;
cout << one << endl;
}
}
void InLine()
{
cout << "以行的形式顯示:\n";
ifstream inFile( "text.txt" );
if ( !inFile )
{
cout << "error opening text.txt\n";
exit(1);
}
char one[80] = "";
while ( !inFile.eof() )
{
inFile.getline( one, sizeof(one) );
cout << one << endl;
}
}
void InChar()
{
cout << "以字符形式顯示:\n";
ifstream inFile( "text.txt" );
if ( !inFile )
{
cout << "error opening text.txt\n";
exit(1);
}
char letter;
while ( !inFile.eof() )
{
inFile.get( letter );
cout << letter << " ";
}
cout << endl;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -