Thread: Problem with understanding exercise 1-18 from K&R

  1. #1
    Registered User
    Join Date
    Jan 2014
    Posts
    76

    Problem with understanding exercise 1-18 from K&R

    I am not able to understand what does the author mean by saying "remove trailing blanks and tabs".

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,352
    Imagine you have a string initialised like this:
    Code:
    char text[] = "Hello world!        ";
    As you can tell, after the last non-whitespace character in the string, there is some whitespace, in this case spaces (or "blanks"). As these come after the non-whitespace, we say that they are "trailing". Your task then is to remove such spaces, but also tabs in a similiar trailing position.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with K&R Exercise 1-23
    By CjStaal in forum C Programming
    Replies: 5
    Last Post: 08-17-2016, 01:15 AM
  2. Understanding an exercise
    By YannB in forum C Programming
    Replies: 1
    Last Post: 01-22-2014, 04:31 PM
  3. Understanding an exercise
    By YannB in forum C Programming
    Replies: 5
    Last Post: 01-20-2014, 02:47 PM
  4. C++ exercise problem
    By Pantheon in forum C++ Programming
    Replies: 13
    Last Post: 09-07-2006, 09:30 AM
  5. new to c. problem with exercise.
    By cakewalkr7 in forum C Programming
    Replies: 4
    Last Post: 04-21-2002, 08:37 PM

Tags for this Thread