0

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

b1urr
  • 1
  • 1
  • I take it you don't understand tab stops? Like in a word processor or text editor? – Garr Godfrey Dec 04 '21 at 20:23
  • 1
    @NickODell Yes that is exactly what I was looking for. I was inserting a fixed number of spaces for each tab, not considering other characters that are in the current column. I just felt like I was missing something and I was. Thanks a ton. – b1urr Dec 04 '21 at 20:28

1 Answers1

1

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␊
ikegami
  • 367,544
  • 15
  • 269
  • 518