Can anyone please help me? I need to remove the first character from a
char * in C.
char * contents contains a
'\n' character as the first character in the array. I need to detect and eliminate this character, modifying the original variable after its been “sanitized”.
Can anyone help me with the code? I’m completely new to C, and just can’t seem to figure it out.
if (contents == '\n') memmove(contents, contents+1, strlen(contents));
Or, if the pointer can be modified:
if (contents == '\n') contents++;
Answered By – ruslik
Answer Checked By – Timothy Miller (BugsFixing Admin)