Topic: look what i just wrote

it solved a problem i've had for the past year or so: emacs.

#include <stdio.h>
main() {
        int c;
        c = getchar();
        while (c != EOF) {
                if (c == 13) {
                        c = 10;
                };
                putchar(c);
                c = getchar();
        };
};

woo!

keywords: fromdos dos2unix osx sucks neil sucks ^M newline newlines

Re: look what i just wrote

That's cool!!! Yet more great uses for C to fix things in the computing world smile

It's funny... as I improve my C abilities, and "read" other code, I find new ways to write bits. So, looking at your code (hope you don't mind) I thought of rewriting it like this:

#include <stdio.h>
int main(void)
{
        int c;
        while ( (c = getchar()) != EOF)
        {
                if (c == 13)
                        c = 10; 
                putchar(c);
        }
}

Hope you don't mind my saying - I was trying to show that I'd actually learnt something tongue   Which is rare for me big_smile  And I revamped my own code example several times tongue

Last edited by WIntellect (2006-01-08 16:46:01)

"UBER" means I don't drink the coffee... I chew the beans instead
             -- Copyright BSDnexus

Re: look what i just wrote

haha.. yeah, neozeed told me that i had errors on lines 8, 11, 12. but i like semicolons at the end of my curlies! it's how my parents raised me!