Let's say that I have
char number[2] = "2";
In my code I get number 2 as a string that's why i have char. Now with the usage of atoi I convert this char to int
int conv_number;
conv_number = atoi(number);
printf("Result : %d\n", conv_number);
which returns me Result : 2. Now I want to put this value in an array and print the result of the array.So I wrote
int array[] = {conv_number};
printf("%d\n",array);
Unfortunately my result is not 2 but -1096772864. What am I missing;
arrayis the address of the array.arrayis not actually an address of the array, rather decays to a pointer to the first element in the array which is equal to the address of the array. Pls correct if am wrong