小编Nuk*_*ons的帖子

从'char'到'const char*'的转换无效

我无法将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)

c++ fstream

1
推荐指数
1
解决办法
3万
查看次数

标签 统计

c++ ×1

fstream ×1