What's wrong?
#include <stdio.h>
#include <string.h>
int main(void) {
char *str= " teste";
int j = 0;
while(str[j] == ' ') j++;
memcpy(str, &str[j], strlen(&str[j])+1);
printf("%s", str);
return 0;
}
When I execute the code I only get as output:
Falha de segmentação (imagem do núcleo gravada)
While I expected spaces to be removed from str
, something close to the trim()
function of javascript.