I was looking for a standard way to remove leading spaces, and I found a pretty simple way using pointers and isspace()
, however our professor won't allow us to use the <ctype.h>
library. Would the following work?
char LeadingSpace(char *line) {
while (line[0] == ' ') {
line++;
}
return line;
}
I'm new to C so not entirely sure how pointers work, but if I move the pointer everytime I find a leading space, then I would only have to check line[0]
, right?