From 060c0d7cf9d6e8975aed0460f297adf9ae71605a Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Fri, 3 Nov 2023 00:20:37 -0400 Subject: [PATCH] adding the two string function notes --- hws/08_youtube_comments/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hws/08_youtube_comments/README.md b/hws/08_youtube_comments/README.md index ae9a0a6..1f7f598 100644 --- a/hws/08_youtube_comments/README.md +++ b/hws/08_youtube_comments/README.md @@ -227,7 +227,7 @@ In this assignment, we define that a child comment should be indented by four sp jsonFile.close(); ``` -After these lines, the whole content of the json file will be stored as a string in the std::string variable *json_content*. And you can then parse it to get each individual comment. +After these lines, the whole content of the json file will be stored as a string in the std::string variable *json_content*. And you can then parse it to get each individual comment. In order to parse the *json_content*, which is a std::string, you will once again find that the std::string functions such as *std::string::find*(), and *std::string**substr*() to be very useful. 2. **The second input file** contains comments, which may have spaces, and that makes it hard for you to use the >> operator to read the content of the file. Once again, the *getline* function can come into play. Let's say you want to read a line like this: @@ -240,7 +240,7 @@ You can use the following lines of code: ```cpp // assuming opsFile is an std::ifstream object, which you use to open the second input file. // assuming command, parent_id, id, author, comment are all std::string objects. - // read the command, the parent comment id, the child comment id, the author, the comment. + // read the command, the parent comment id, the child comment id, the user name. opsFile >> command; opsFile >> parent_id; opsFile >> id;