Scanning from specific variable using cin

What is the cin equivalent of the scanf() code written below? I am only aware of cin >> a[i] >> b[i].

scanf_s("x=%d(mod %d)\n", &a[i], &b[i]);

1 answer

  • answered 2021-10-24 18:23 Remy Lebeau

    The std::cin equivalent would be to use std::getline() to read the entire user input as-is from std::cin into a std::string, and then parse the string as needed, such as with string::find() and string::substr(), or std::regex, etc.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum