我无法将char加载到我的一个函数中.这是我开始使用的源代码.
main.cpp中
#include <IOF\IOF.h>
int main()
{
char load;
string intro = LoadFileToString( "Intro.txt" );
cout << intro << "> ";
cin >> load;
string loadedFile = LoadFileToString( load );
cout << loadedFile;
cin.get();
cin.ignore();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
IOF.h
#ifndef IOF_H
#define IOF_H
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
string LoadFileToString( const char * filePath )
{
string fileData;
ifstream loadFile( filePath, ios::in );
if ( loadFile.is_open() )
{
string line;
while ( getline( loadFile, line ) …Run Code Online (Sandbox Code Playgroud)