Convert a number from string to integer without using inbuilt function
Posted
by
Raja
on Stack Overflow
See other posts from Stack Overflow
or by Raja
Published on 2011-03-13T15:55:07Z
Indexed on
2011/03/13
16:10 UTC
Read the original article
Hit count: 177
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'
© Stack Overflow or respective owner