Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
現在、スペースを含む入力を読み取るために実行しています。
int main() { char str[100]; string st; cin.getline(str,100); st=str; }
文字列に付属する関数を利用したいので、入力を文字列に読み込んでいます。入力を文字列に直接読み取る他の方法はありますか?これもスペースを許可します。
std::stringオブジェクトを使用する場合は、を使用してくださいstd::getline。
std::string
std::getline
std::string st; std::getline(std::cin, st);
get()関数を使用します。
入力として偶数スペースを受け入れます。
例えば。)。
gets (variable_name);