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



"Patrick M." wrote:
>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?
>
Almost there... They are asking for a program that will take as input:

(a) A text file containing some tab characters. And
(b) A number 'N' telling what is the tab "spacing"

And produce, as output, a text file where every tab has been replaced
by a *variable* number of spaces between 1 and N so that the file
"looks" similar to the original when displayed or printed in a device
that uses 'N' colums per tab.

For example, if N is 4 and the original file is:

int i = 0;
int jj = 0;
int kkk = 0;

Containing a tab before each 'int', a space after each 'int' and a tab
before each '=', the output should be:

int i = 0;
int jj = 0;
int kkk = 0;

containing 4 spaces before each int, one space after each int, 3
spaces after 'i', 2 spaces after 'jj' and 1 space after 'kkk';



Roberto Waltman

[ Please reply to the group, ]
[ return address is invalid. ]
.



Relevant Pages

  • A source file de-tabifier for you
    ... *transform* one tab setting to another; thus, you can write your code with ... void do_line; ... int reset_on_com = FALSE; ... char **argv; ...
    (alt.comp.lang.learn.c-cpp)
  • Re: newbie question
    ... int main{ ... The problem is that some news readers clients (or is it some news ... server, I don't know) strip the TAB and consequently, your code appears ...
    (comp.lang.c)
  • Re: exercise 1-20 K&R
    ... of blanks to space to the next tab stop. ... int counter, c; ... character count for the current line, ... Tab stops are at the same character number (modulo TABSIZE) throughout ...
    (comp.lang.c)
  • [patch 1/14] s3c2412/s3c2413 support
    ... +s3c_lookup_cpu(unsigned long idcode,int alt) ... struct cpu_table *tab; ... int count; ...
    (Linux-Kernel)
  • Re: [OT] CVS diff: hard vs. soft tabs
    ... > | originally saved to disk with hard tabs for indenting. ... > | show up as different just because of tab characters, ... turns out my original file wasn't quite in the format i thought it ... was, but knowing these tricks, i was able to reformat and re-check-in ...
    (Debian-User)