You should use malloc if you need a system to provide you with memory to store data. For example, if you want to save a string, you must allocate memory for it
char* s = malloc(10);
strcpy(s, "something");
If you only need a pointer that indicates what is already in memory, you should not select it, in your case, the function strchrreturns a pointer that points to the position in memory where the char is cin the strings
char* c;
c = strchr(s, 'm');
Mr. E source
share