char pointer v.s. char array

This note is to compare difference between pointer and array in C.[1]

  1. const character pointer
const char* s = "hello";
  1. character pointer with initialized string
char* s = "hello";
  1. character pointer with string
char* s = malloc(5);
  1. character array by given string
char s[] = "hello";
  1. character array by given fixed size
char s[10] = "hello";

  1. https://stackoverflow.com/questions/25653034/the-difference-between-char-and-char ↩︎