Find the size of a string pointed by a pointer

Use strlen to find the length of (number of characters in) a string

const char *ptr = "stackoverflow";
size_t length = strlen(ptr);

Another minor point, note that ptr is a string literal (a pointer to const memory which cannot be modified). Its better practice to declare it as const to show this.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)