I have two questions:
Q1. The character pointers are used to point to a location where a given string is stored. If we keep reassigning the string, does it lead to memory leak?
On a Linux system I see:
$ cat chk.c
#include <stdio.h>
#define VP (void *)
int main()
{
char *str;
str = "ABC";
printf("str = %p points to %s\n", VP str, str);
str = "CBA";
printf("str = %p points to %s\n", VP str, str);
return 0;
}
$ cc chk.c && ./a.out
str = 0x8048490 points to ABC
str = 0x80484ab points to CBA
$
Q2. What is the maximum length of a string that can be assigned as above?