搜尋此網誌

2026年1月20日星期二

Open a txt file for reading

reading file: ifstream (input file stream)

writing file: ofstream (output file stream)

eof() in C++ is a member function of file stream classes (ifstream, ofstream, fstream) that stands for end-of-file.

stoi in C++ stands for "string to integer".


Meaning of letter = str[0];

  • str → a std::string object.
    • [0] → accesses the first character of the string (indexing starts at 0).
    • letter → a variable of type char that stores the result.

    So this statement assigns the first character of the string str to the variable letter


    Microsoft Copilot

    沒有留言:

    發佈留言