I'm using the following code to do so:
The problem is I can't an integer more than 9 as it is. For example, the array is reading and converting each char separately, so for example if I want to get 34 form char array into an integer 34, it won't do so. It picks and gives 3 separately and 4 separately.Code:#include <stdio.h> int main () { int i; char ch[20]="1 2 34 4 56672332432"; int ch1[20]; for (i=0; i<20; i++) { ch1[i]=(int)ch[i]-'0'; } for (i=0; i<20; i++) { printf ("%d\n ", ch1[i]); } return 0; }
What should I do for this problem?