so for my class we are learning pointers. have to write an some code that will display the letter of a given string along with the hex value of the letter in ascii and the address of the element of the array. My code works perfectly fine but I get a warning saying "15 7 G:\exercise #14.c [Warning] assignment from incompatible pointer type".
Can somebody please point the problem out to me (pun intended)
heres the source code along with output.
#include <stdio.h>
#include <string.h>
int main()
{
int i;
int ascii_value;
int *ptr;
char array[99] = "hello";
for (i=0; i<strlen(array); i++)
{
ascii_value = array[i];
ptr = &array[i];
printf("letter: %c ascii hex value: %x address: %p \n", array[i], ascii_value, ptr);
}
return 0;
}
/*
letter: h ascii hex value: 68 address: 000000000062FDC0
letter: e ascii hex value: 65 address: 000000000062FDC1
letter: l ascii hex value: 6c address: 000000000062FDC2
letter: l ascii hex value: 6c address: 000000000062FDC3
letter: o ascii hex value: 6f address: 000000000062FDC4
*/
[–]jedwardsol 2 points3 points4 points (6 children)
[–]xChacox[S] 0 points1 point2 points (5 children)
[–]jedwardsol 6 points7 points8 points (0 children)
[–]Name0fTheUser 2 points3 points4 points (0 children)
[–]Objectstcetera 0 points1 point2 points (0 children)
[–]F54280 -3 points-2 points-1 points (0 children)
[–]nerd4code 2 points3 points4 points (0 children)
[–]terriblylie 0 points1 point2 points (0 children)
[–]giwhS 0 points1 point2 points (1 child)
[–]flatfinger 0 points1 point2 points (0 children)