C++ 从文件中读取会导致重音“;a「';空间里有什么
我试图阅读,只采取行动和参数,并忽略一切,包括后斜杠(只有“NCORES 2”,“切片100”,等等)。它按照预期将“NCORES”和“2”作为字符串和整数分开。然而。显然,它读取整个“SLICE 100”作为参数,而不是下一行。我不知道为什么C++ 从文件中读取会导致重音“;a「';空间里有什么,c++,C++,我试图阅读,只采取行动和参数,并忽略一切,包括后斜杠(只有“NCORES 2”,“切片100”,等等)。它按照预期将“NCORES”和“2”作为字符串和整数分开。然而。显然,它读取整个“SLICE 100”作为参数,而不是下一行。我不知道为什么 #include <iostream> #include <string> #include <sstream> using namespace std; struct node { string a
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
struct node {
string action;
int parameter;
node* next;
node* prev;
};
int main() {
int time = 0; //in milliseconds
string action;
int parameter;
string misc;
/*node* head;
node* tail;
node* n;
n = new node; //makes new node and n points to it
n->parameter = 1;
n->prev = NULL;
head = n;
tail = n;
n = new node;
n->parameter = 2;
n->prev = tail;
tail->next = n;
tail = n;
*/
for(int i = 0; i<10; i++){
cin>>action>>parameter;
//cout<< action << parameter<<endl;
cout<< action <<endl;
if(i==0){
std::cin.ignore(100,'\n'); //Ignore until new line
}
}
std::cin.ignore();
return 0;
}
#包括
#包括
#包括
使用名称空间std;
结构节点{
弦作用;
int参数;
节点*下一步;
节点*prev;
};
int main(){
int time=0;//以毫秒为单位
弦作用;
int参数;
字符串杂项;
/*节点*头;
节点*尾部;
节点*n;
n=new node;//创建新节点,n指向它
n->参数=1;
n->prev=NULL;
水头=n;
尾=n;
n=新节点;
n->参数=2;
n->prev=尾部;
tail->next=n;
尾=n;
*/
对于(int i=0;i>操作>>参数;
//couty您的文本文件和输出应该以文本格式发布在您的问题中。您还应该提供一个演示您的问题的示例。使用“最小值”,我的意思是你应该去掉所有不必要的、不相关的东西,比如注释掉的代码和未使用的节点结构。我的灵力告诉我文本文档中的东西不是空格(U+0020)。它们是不间断的空格(U+00A0).我的灵能告诉我你正在把它们印成mojibake in,其中A0代表á
。