小编Bry*_* S.的帖子

阻止 getline 丢弃换行符

如果我有一个像这样的文本文件:

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)

c++ newline getline

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

Visual with std :: transform中的错误C3861

我有点好奇为什么我在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)

c++ transform

0
推荐指数
1
解决办法
7187
查看次数

标签 统计

c++ ×2

getline ×1

newline ×1

transform ×1