Re: K&R exercises



mdh wrote:
Now, there are
numerous anwers on the web and in the "C answer book", which includes a
function to expand the tabs to blanks ( depending upon where the tab is
in relationship to the next tab-stop). I have been trying to understand
why one would do this....why not just leave the tabs alone.

Not even sure if I should have asked this, but anyway.....

Suppose I have my tabs set to eight spaces

#include <stdio.h>
int main(void) {
char name[30]; /* user's name */
fgets(name, 30, stdin); /* needs error checking */
printf("Hello, %s!", name); /* greet user */
return 0; /* and exit */
}

and Louise, who prefers three spaced tabs, opens my source file

#include <stdio.h>
int main(void) {
char name[30]; /* user's name */
fgets(name, 30, stdin); /* needs error checking */
printf("Hello, %s!", name); /* greet user */
return 0; /* and exit */
}

So if there's a chance Louise will see my code, I'd rather make her have
some extra work to format the coding to her liking, than to have her see
that mess you see up there :)

--
If you're posting through Google read <http://cfaj.freeshell.org/google>
.



Relevant Pages

  • Re: stream io in c
    ... If you are using tabs to indent your code, consider switching to spaces, ... And note that 'c' is declared as an int, ... unsigned char. ...
    (comp.lang.c)
  • Re: Help me regarding this topic
    ... - is there a compiler error message? ... Most editors and IDEs I've used allow you to configure them so that tabs are always converted to spaces. ... Cariable names should start with lower case ("english" instead of "English") otherwise you confuse readers by making variable names look like class names. ... int Mathmatics = Integer.praseInt); ...
    (comp.lang.java.programmer)
  • Re: Cannot find error on my program ( verry basic C stuff )
    ... and i agree that this code is not clean at all lol, ... int getline; ... supposed to do - it removes leading tabs and blanks and if there ... inspace = OUT; ...
    (comp.lang.c)
  • Re: Cannot find error on my program ( verry basic C stuff )
    ... and i agree that this code is not clean at all lol, ... /* Remove trailing blanks and tabs from each line ... int getline; ... inspace = OUT; ...
    (comp.lang.c)
  • Re: stl vector find.
    ... I'm going to modify the file format a bit -- the ... delimiters between fields will be only tabs, and for convenience, I've ... int school; ... // show the whole contents of the map, to show we read it right. ...
    (alt.comp.lang.learn.c-cpp)