How can I perform this code in C and C++? [closed]

Solution 1:

I think it will be something like this

std::string num = "";
while isdigit(current_char){
    num += current_char;
}