write blocks (words) at once, not chars

This commit is contained in:
Loic Nageleisen 2013-02-01 21:08:42 +01:00
parent 8751323eb2
commit cda16d2a1b

9
main.c
View file

@ -75,10 +75,15 @@ void Post_init(Post *self) {
} }
void Post_printf(Post *self) { void Post_printf(Post *self) {
for(char *buf = self->body; *buf != '\0'; buf++) { char *nosp = NULL;
for (char *buf = self->body; *buf != '\0'; buf++) {
if (*buf != ' ') { if (*buf != ' ') {
printf("%c", *buf); nosp = nosp == NULL ? buf : nosp;
} else { } else {
if (nosp != NULL) {
fwrite(nosp, sizeof(char), buf - nosp, stdout);
nosp = NULL;
}
if (*(buf+1) != ' ' && if (*(buf+1) != ' ' &&
*(buf+1) != '\0' && *(buf+1) != '\0' &&
*(buf+1) != '\n') { *(buf+1) != '\n') {