Re: I don't quite understand this exercise...



Thad Smith wrote:
Patrick M. wrote:

I don't quite understand what K&R want me to do in Exercise 1-20 in "The C Programming Language, 2nd Edition". Here's the description:

"Write a program detab that replaces tabs in the input with the proper number of blanks to space to the next tab stop. Assume a fixed set of tab stops, say every n columns. Should n be a variable or a symbolic parameter?"

What does this mean? Do they want me to figure out the amount of spaces a tab takes up on my system, and add them? I'm sort of confused about this question.

They mean: write a program to read a text file (or stdin) with tabs and replace all the tabs with equivalent space characters. The result should be an output file (or stdout). This is a general type of program known as a filter, which takes one input file and produces an associated output file with some defined modification.


They are suggesting that you might want to allow some way to specify the tab spacing or tab columns that your input file assumes. That can be done with a command line parameter.

Thad


Ok, thanks, and everyone else. So what you're saying is, they want me to ask the user/get and set a variable, say n, and replace all tabs with n spaces, and they don't want me to calculate the number of spaces a tab takes up on the system?


Thanks for all the replies.

--
Patrick M.
/* EOF */
.



Relevant Pages

  • Re: I dont quite understand this exercise...
    ... "Write a program detab that replaces tabs in the input with the proper number of blanks to space to the next tab stop. ... This is a general type of program known as a filter, which takes one input file and produces an associated output file with some defined modification. ... They are suggesting that you might want to allow some way to specify the tab spacing or tab columns that your input file assumes. ...
    (comp.lang.c)
  • Re: Data and File I/O
    ... >you basically just need to open an output file, and as you read in the data, ... >If it is a tab then just write out 4 spaces, ... http://mindprod.com Java custom programming, consulting and coaching. ...
    (comp.lang.java.programmer)
  • Re: convert text file to excel ? (continued)
    ... Parsing the input, creating the output, creating the output file, writing to the output file, etc? ... need the headings, moves over 10 spaces and inserts a tab, moves over ...
    (microsoft.public.dotnet.languages.vb)
  • Re: simple form need tab for blank checkbox
    ... > Hi I have a simple webform which is processed with php. ... > field gives a tab in the output file but I also need empty checkboxes ... > to return a tab. ...
    (comp.lang.php)
  • simple form need tab for blank checkbox
    ... Hi I have a simple webform which is processed with php. ... field gives a tab in the output file but I also need empty checkboxes ... to return a tab. ...
    (comp.lang.php)