Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 928413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:00:18+00:00 2026-05-15T20:00:18+00:00

Write a program to copy its input to its output, replacing each string of

  • 0

“Write a program to copy its input to
its output, replacing each string of
one or more blanks by a single blank.”

I’m assuming by this he means input something like…

We(blank)(blank)(blank)go(blank)to(blank)(blank)(blank)the(blank)mall!

… and output it like:

We(blank)go(blank)to(blank)the(blank)mall!

This is probably easier than I’m making it out to be, but still, I can’t seem to figure it out. I don’t really want the code… more so pseudo code.

Also, how should I be looking at this? I’m pretty sure whatever program I write is going to need at least one variable, a while loop, a couple if statements, and will use both the getchar() and putchar() functions… but besides that I’m at a loss. I don’t really have a programmers train of thought yet, so if you could give me some advice as to how I should be looking at “problems” in general that’d be awesome.

(And please don’t bring up else, I haven’t got that far in the book so right now that’s out of my scope.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:00:18+00:00Added an answer on May 15, 2026 at 8:00 pm

    Pseudo code

    while c = getchar:
        if c is blank:
            c = getchar until c is not blank
            print blank
        print c
    

    C

    You can substitute use of isblank here if you desire. It is unspecified what characters contrive blank, or what blank value is to be printed in place of others.

    After many points made by Matthew in the comments below, this version, and the one containing isblank are the same.

    int c;
    while ((c = getchar()) != EOF) {
        if (c == ' ') {
            while ((c = getchar()) == ' ');
            putchar(' ');
            if (c == EOF) break;
        }
        putchar(c);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 535k
  • Answers 535k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you mean to be using the jQuery function .not,… May 17, 2026 at 1:10 am
  • Editorial Team
    Editorial Team added an answer Yes it is. The IFilters run inside a hosting process… May 17, 2026 at 1:10 am
  • Editorial Team
    Editorial Team added an answer Basically you want to ignore scores with fewer than x… May 17, 2026 at 1:10 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm doing K&R's Exercise 1-10 Write a program to copy its input to its
Hey i am hoping to write a program where the program automatically just copy
I'm on to K&R's Exercise 1-18 Write a program to remove trailing blanks and
Within a VB.NET program, I want to read files from a filesystem, then write
I am trying to write a program that supports speech recognition via a custom
Update2: For now, I'm considering saving a temporary copy of the document in html
I'm searching a software (web-based, php/mysql) that allows users to (anonymously/with registering) write suggestions
I came across a interview question that asked to remove the repeated char from
I'm working through the exercises in Accelerated C++ and I'm stuck on question 5-6.
Suppose you have a subsystem that does some kind of work. It could be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.