mirror of
https://github.com/ShusenTang/LeetCode.git
synced 2024-09-02 14:20:01 +00:00
add comment about istringstream
This commit is contained in:
parent
b420ed4bae
commit
52c2f4da3d
@ -32,7 +32,7 @@ istream& getline (istream&& is, string& str);
|
||||
```
|
||||
函数的变量:
|
||||
```
|
||||
is :表示一个输入流,例如cin。本题我们用到的是stringstream。
|
||||
is :表示一个输入流,例如cin。本题我们用到的是stringstream或者istringstream。
|
||||
str :string类型的引用,用来存储输入流中的流信息。
|
||||
delim :char类型的变量,所设置的截断字符;在不自定义设置的情况下,遇到’\n’,则终止输入。
|
||||
```
|
||||
@ -78,7 +78,7 @@ public:
|
||||
string simplifyPath(string path) {
|
||||
string res, tmp;
|
||||
vector<string> stk;
|
||||
stringstream ss(path);
|
||||
stringstream ss(path); // or istringstream ss(path);
|
||||
while(getline(ss,tmp,'/')) {
|
||||
if (tmp == "" or tmp == ".") continue;
|
||||
if (tmp == ".." and !stk.empty()) stk.pop_back();
|
||||
|
Loading…
Reference in New Issue
Block a user