如果我有一个像这样的文本文件:
this is line one
This is line two
this is line three
Run Code Online (Sandbox Code Playgroud)
我将如何使用 getline 将每个读入字符串流,然后将流打印到新字符串中,同时保留换行符?我在一台使用 Xcode 4 的 Mac 上。这是我的代码: 我遇到了麻烦,因为它打印出来的文本只打印在一行上。
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <cctype>
using namespace std;
string getInput ();
ifstream * openInFile ();
int getShiftValue ();
void cypherMenu ();
void menu ();
string shiftCharacters (int shiftNum, ifstream * inFile);
string getOutput ();
ofstream * openOutFile ();
void printSentence (string outData, ofstream * outFile);
void notOption (string optionString);
string capitalize …Run Code Online (Sandbox Code Playgroud) 我有点好奇为什么我在Xcode上使用mac编写的程序运行良好,但是当我尝试使用visual studio编译windows系统时,
我收到以下错误:
c:\ users\bryan\documents\visual studio 2010\projects \new \new \new.cpp(172):错误C3861:'transform':找不到标识符.
实际上,当我在程序中的任何地方编写转换时,它会显示相同的消息,就好像transform不是std命名空间的一部分一样.如果您想亲眼看看,这是我的代码:
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <cctype>
using namespace std;
string getInput ();
ifstream * openInFile ();
int getShiftValue ();
void cypherMenu ();
void menu ();
string shiftCharacters (int shiftNum, ifstream * inFile);
string getOutput ();
ofstream * openOutFile ();
void printSentence (string outData, ofstream * outFile);
void notOption (string optionString);
string capitalize (string choice);
string option ();
int main() {
ifstream * inFile; …Run Code Online (Sandbox Code Playgroud)