Convert a number from string to integer without using inbuilt function
- by Raja
I am trying this technique but error is coming. Please help me to convert a number from string to integer.
#include<iostream>
using namespace std;
int main()
{
char *buffer[80];
int a;
cout<<"enter the number";
cin.get(buffer,79);
char *ptr[80] = &buffer;
while(*ptr!='\0')
{
a=(a*10)+(*ptr-48);
}
cout<<"the value"<<a;
delete ptr[];
return 0;
}
Errors are:
error C2440: 'initializing' : cannot convert from 'char ()[80]' to 'char *[80]'
error C2440: '=' : cannot convert from 'char *' to 'int'