char to const char*

What is the easiest way to get around this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;

int main(int argc, char** argv)
{
    if(argc !=2) return -1;
    else
    {
	   unsigned int current;
	   unsigned int max = 0;
	   for( int i = 4; i < strlen(argv[1]); i+=5 )
	   {
	        current = atoi(argv[1][i]) * atoi(argv[1][i-1]) * atoi(argv[1][i-2]) * atoi(argv[1][i-3]) * atoi(argv[1][i-4]);    
	        if( current > max ) max = current;
	   }
	   cout << max <<endl;
	}
}
I'm guessing this is what you're trying to do:
1
2
3
int not_atoi(char c){
    return c - '0';
}
Nice, thanks.
I knew there had to be a simple way of doing that.
Topic archived. No new replies allowed.