[comp.lang.c] Novice C

R.Smithers@ee.surrey.ac.uk (Russell Smithers) (05/21/91)

	I would normaly e-mail directly to people but in this case I could not
as the mail address i used was wrong and by that time I had quit that group on xrn and could not find another suitable address so heres my answer:

        Heres a program I wrote to do the same thing ill convert it
to work with arrays if you want :

#include <stdio.h>
#include <ctype.h>

main()
{
        char tst;
        int mat=1;

        while((tst=getchar())!=EOF)
        {
                /* 13 being ^M */
                if (tst==13) printf ("\n");
                else
                        printf ("%c",tst);
        }
}


Basicly what this program does is to read from stdin a character at
a time and looks for ^M if it finds one then it prints to stdout the
"\n"(carriage return) (this being what is should be, however if you
want to replcae this (^M) with a space heres the code :

#include <stdio.h>
#include <ctype.h>

main()
{
        char tst;
        int mat=1;

        while((tst=getchar())!=EOF)
        {
                /* 13 being ^M */
                if (tst==13) printf (" ");
                else
                        printf ("%c",tst);
        }
}


PS No flames.

Russell Smithers,

Computing Assistant, Dept. of Mathematical and Computing Sciences
          University of Surrey, Guildford, Surrey GU2 5XH, England
R.Smithers@cs.surrey.ac.uk                                 +483 571281 x2659

Shock me put on your black leather!!