Skip to content

Instantly share code, notes, and snippets.

@naohaq
Created June 20, 2012 01:15
Show Gist options
  • Save naohaq/2957546 to your computer and use it in GitHub Desktop.
Save naohaq/2957546 to your computer and use it in GitHub Desktop.
Delete characters on heads of lines.
#include <stdio.h>
int
main( )
{
int c;
int newl = 0;
while((c = getchar( )) != EOF) {
if (c == '\r' || c == '\n') {
newl = 1;
putchar(c);
}
else {
if (newl) {
newl = 0;
}
else {
putchar(c);
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment