Iteration of int like string (Python -> C++) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Iteration of int like string (Python -> C++)

How to do this on C++ ? number=5342 for a in str(number): my_function(int(a))

2nd May 2020, 12:53 AM
Quarz
1 Answer
+ 1
#include <cstdlib> for (char c : itoa(number)) my_function (stoi(c));
2nd May 2020, 1:13 AM
Mustafa K.
Mustafa K. - avatar