Error of reading character c + +

this is a very subtle error
this error means that the memory that the variable reads holds a data type that is actually a sequence of characters, not the data type specified by the variable type.

the general reason for this error is:

char* buffer = (char*)malloc(sizeof(char) * 1024);
char *p =  NULL;

what happens when the buffer contains more than 1024 bytes of data?
yes, the value of p is overwritten by buffer. When checking p during debugging, it will be found that p is no longer NULL, and the error will be “error reading character of string”.

C++, we still try to use STL containers, because STL containers will automatically expand. If above code is:

std::string buffer;
char *p =  NULL;

I believe this error will not occur again.

Read More: