#include<stdio.h>
#include<stdlib.h>
#define LENGTH 5
void convert ( char parray[] ,int array[] )
{
int i;
for (i=0; i< LENGTH; i++)
{
array[i] = atoi(&parray[i]);
printf(" The converted array is %d\n" , array[i]);
}
}
int main ()
{
char parray[LENGTH] = { '7', '1', '4','5' ,'2'};
int iarray[LENGTH];
convert(parray, iarray);
}
******** Output *********
The converted array is 71452
The converted array is 1452
The converted array is 452
The converted array is 52
The converted array is 2
But I want the following output like this
The converted array is 7
The converted array is 1
The converted array is 4
The converted array is 5
The converted array is 2
It should store value of 7 in array[0]
, 1 in array[1]
!!!! Please help