I wanna illustrate the difference between a char array (a string that is) and a pointer to char
Perhaps this might help (the code is C99, the concept is the same in C89):
Code:
#include <stdio.h>
static void print_object(const void *p, size_t s)
{
printf("Object %p:\n", p);
for(size_t i = 0; i < s; i++) printf("%hhu\n", ((unsigned char*)p)[i]);
}
int main(void)
{
char string1[] = "this is a string";
const char *string2 = "this is a string";
print_object(&string1, sizeof string1);
print_object(&string2, sizeof string2);
return 0;
}
Maybe just printing out the result of sizeof on each object is enough to show the difference, too. I guess it depends on how convincing you're trying to be.