Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <iostream>

using namespace std;

int cast_to_int(string num);


int num_of_chr(string to_count);
int pwr(int base, int power);

int main(){
cout<<pwr(10, 2);
return 0;
}

int cast_to_int(string num){


char chr[] = "0123456789";
string* strng_pntr = &num;
int rtrn(0);
int deduct = 1;
int num_of_char = num_of_chr(num);
for(int i = 0 ; i<= num_of_char; i++){
while(strng_pntr != '\0'){
if(strng_pntr[i] = chr[i]){
rtrn += i*pwr(10,(num_of_char - deduct));
deduct--;
}
}
*strng_pntr++;
}
return rtrn;
}

int num_of_chr(string to_count){


int countt = 0;
for(int i = 0; ; i++){
countt++;
if(to_count[i] == '\0'){
break;
}
}
return countt-1;
}

int pwr(int base, int power){


int product(1);
for(int i = 0 ; i<power ; i++){
product = product*base;
}
return product;
}

You might also like