Something roughly equivalent would be
However, if you're trying to rewrite a piece of code to use C++ idioms, you should not rewrite each line in isolation; you should rewrite considering context.
It's like when you're translating, if you translate word-for-word you're going to end up with something that's possibly comprehensible but probably clunky, and at worst nonsensical. You need to understand the idea the author was trying to communicate and then express that idea in the target language.
So, for example, if your original code said
1 2
|
char str[700];
scanf("%s", str);
|
you should not replace that with
1 2
|
std::string str(700, 0);
std::cin >> str;
|
Instead, use
1 2
|
std::string str;
std::cin >> str;
|
1. Understand what the original code is supposed to accomplish.
2. Understand the classes and functions C++ provides.
3. Write C++ code that cleanly and idiomatically expresses that original intention.