Re: Problem with printing input.



this program assumes that the words in a line are separated only by one
space.
but writing a program that handles variable number of spaces is a
breeze once u know the basic logic.
Walter Roberson wrote:
> In article <1114061152.442467.165550@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
> <ramakrishnat@xxxxxxxxx> wrote:
> >try execute this program ...
>
> >#include <stdio.h>
>
> >/* print the input one word per time on different lines */
>
> >int main(void)
> >{
> > int c;
> > while ((c = getchar()) != EOF) {
> > if (c == ' ' || c == '\n' || c == '\t')
> > putchar('\n');
> > else
> > putchar(c);
> > }
> > return 0;
> >}
>
> And if the input is
>
> hey you rama krishna
>
> is your program going to print one word per line?
> --
> "Never install telephone wiring during a lightning storm." --
Linksys

.



Relevant Pages

  • Re: "EXT3-fs error" after resume from s2ram
    ... INT A disabled ... writing 0xe2000008) ... connection state: disconnected -> associated ... setting latency timer to 64 ...
    (Linux-Kernel)
  • Re: Rookie Student C++ Array question (reading from a file)
    ... >Start by writing down in plain english words what needs to be done. ... >int main ... >That's your overall plan. ... at the previous suggestion of mapping, ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Rookie Student C++ Array question (reading from a file)
    ... >Start by writing down in plain english words what needs to be done. ... >int main ... >That's your overall plan. ... >do the additions inline in your real source code) ...
    (alt.comp.lang.learn.c-cpp)
  • Re: read and write columns
    ... You attempt to open the same file, "data", for writing and reading, ... Read the documentation for fscanf. ... int main ...
    (comp.lang.c)
  • Re: Inheritable Static methods
    ... the former encapsulates the conversion into the int type. ... writing "typeof.FullName" might not look quite as nice as "someClass.FullName". ... you've got a perfectly good alternative syntax that does _exactly_ the same thing. ...
    (microsoft.public.dotnet.languages.csharp)