Read C++ string with scanf

后端 未结 7 1020
离开以前
离开以前 2020-11-28 12:35

As the title said, I\'m curious if there is a way to read a C++ string with scanf.

I know that I can read each char and insert it in the deserved string, but I\'d wa

相关标签:
7条回答
  • 2020-11-28 13:22

    The below snippet works

    string s(100, '\0');
    scanf("%s", s.c_str());
    
    0 讨论(0)
提交回复
热议问题