#include <stdio.h> #include <iostream> using namespace std; int string_length(char *s) { int n = 0; while (s[n]) n++; return n; } int pow10(int exp) { int n = 1; for (int i = 0; i < exp; i++) n *= 10; return n; } void string_to_integer() { char s[10] = "26962869"; int length =string_length(s); int n = 0; for (int i = 0; i < length; i++) n += (s[i] - '0') * pow10(length - 1 - i); cout << n; } void string_to_integer2() { char s[10] = "26962869"; int n = 0; for (int i = 0; s[i]; i++) n = n * 10 + s[i] - '0'; cout << n; }