Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
131 views
in Technique[技术] by (71.8m points)

c++ - understanding a function stringstream

I'm trying to understand this stringstream function stringstream ss(line); not quite sure what it's purpose is or what it does.

I'm really new to C++ so I'm sorry if this really simple and stupid. Anything helps thanks!

c++

float process(float Beta, std::ifstream & INPUT, float mass, float energy, int Juse = 1, int Jerror = 1, int intype = 1)

{
    float crosscons = 8 * M_PI * mass * mass / energy; //Creates a constant that is used to calculate the cross section

    int dwarf_count = 0;
    int dcol = 0;
    string line;
    string item;
    int header = 0;
    string skip("#"); 
    INPUT.seekg(0, ios::beg); 
    while (getline(INPUT, line))
      
    {
        if (contains(line, skip))
        {
            header++;
        } else {
            break;
        }

    }

    INPUT.seekg(0, ios::beg); // same as above, searching for the INPUT i.e File.
    for (int i = 0; i < header; ++i)
    {
        getline(INPUT, line);

    }
    while (getline(INPUT, line))
    {
        ++dwarf_count;
        if (dwarf_count == 1)
        {
            stringstream ss(line);
            while (ss >> item)
                dcol++; // creates a variable in the while loop, that probably means column
        }

    }
question from:https://stackoverflow.com/questions/65950443/understanding-a-function-stringstream

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...