What exactly are these questions asking?

61 views Asked by At

I am reading the C programming textbook by Dennis Ritchie and Brian Kernighan. I finished the first chapter and stumbled across these questions that I'm not sure I'm interpreting correctly. Specifically, in Exercise 1-20, what does the authors mean when they say "Assume a fixed set of tab stops, say every n columns." I am also only trying to use the content presented in chapter 1 which includes: simple arrays, functions, symbolic constants, getchar(), putchar() and printf().

Screenshot of questions

1

There are 1 answers

0
ikegami On

It means that you should convert each tab ('\t', or 0x09 on ASCII-based machines) into a non-zero number of spaces that brings the cursor to the next multiple of n.

For example,

Input:

  +---+----+------ Tabs
  |   |    |
ab␉cde␉fghi␉j␊
             |
             +---- Line Feed

Output: (The ruler is just for reference)

|...|...|...|...|...   n=4
ab  cde fghi    j␊