Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int stringtoint(string liczba)
- {
- int wynik = 0, potega = 1;
- for(int i = (liczba.size() - 1); i >= 0; --i)
- {
- wynik += (static_cast<int>(liczba[i]) - 48) * potega;
- potega *= 10;
- }
- return wynik;
- }
- int main()
- {
- string liczba = "15716";
- int iliczba = stringtoint(liczba);
- cout << iliczba << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement