Not sure what is the error in this code. This is from the book called "Understanding and Using C Pointers". This is from page number 36. It is supposed to demonstrate that we allocate 6 bytes in memory bt we use 8 bytes.
However, when I run it, I get the following error.Code:#include <stdio.h>
#include <stdlib.h>
int main() {
char *pc = (char*) malloc(6);
for(int i=0; i<8; i++) {
*pc[i] = 0;
}
}
Quote:
error: invalid type argument of unary '*' (have 'int')