Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #6010

Re: program which removes comments from C source

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c
Subject Re: program which removes comments from C source
Date 2011-06-14 14:57 +1200
Message-ID <95o108F4dhU1@mid.individual.net> (permalink)
References <a6268caf-18a8-4e8f-9b2e-433fc57397a8@j31g2000yqe.googlegroups.com> <4aacecf9-baa1-40a4-a128-e48922b5a999@v8g2000yqb.googlegroups.com>

Show all headers | View raw


On 06/14/11 02:37 PM, Ceriousmall wrote:
> On Jun 13, 8:20 pm, Ceriousmall<divadsm...@gmail.com>  wrote:
> I just need some feedback on this code. Its one  of the K&R exercises.
>
>   /* 2011/05 Ceriousmall. . . .
>    * this program is code-named delcom and as such it deletes all
>    * comments from a C Program. . . . */
>
>   #include<stdio.h>
>
>   #define ASTR    '*'
>   #define BSLASH  '/'
>   #define FSLASH  '\\'
>   #define DBQTS   '\"'
>   #define SNQTS   '\''
>   #define SPC     ' '

Just a general observation while you sort out your layout!

As Keith pointed out, those defines are more trouble than they are 
worth.  If you are going to use them, use something with a meaningful 
name, such as

const char space = ' ';

Similarly for the function names, rather than 'delcom' accompanied by 
explanatory comments, give the function a name like 
'removeCommentsFromLine'.

A good general rule is if something requires an explanatory comment, it 
is wrongly named.

-- 
Ian Collins

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

program which removes comments from C source Ceriousmall <divadsmall@gmail.com> - 2011-06-13 18:20 -0700
  Re: program which removes comments from C source Ceriousmall <divadsmall@gmail.com> - 2011-06-13 18:23 -0700
  Re: program which removes comments from C source Keith Thompson <kst-u@mib.org> - 2011-06-13 19:23 -0700
  Re: program which removes comments from C source Ceriousmall <divadsmall@gmail.com> - 2011-06-13 19:37 -0700
    Re: program which removes comments from C source Ceriousmall <divadsmall@gmail.com> - 2011-06-13 19:41 -0700
    Re: program which removes comments from C source Ian Collins <ian-news@hotmail.com> - 2011-06-14 14:57 +1200
  Re: program which removes comments from C source Ceriousmall <divadsmall@gmail.com> - 2011-06-13 19:53 -0700
    Re: program which removes comments from C source Ike Naar <ike@iceland.freeshell.org> - 2011-06-14 07:23 +0000
      Re: program which removes comments from C source Ceriousmall <divadsmall@gmail.com> - 2011-06-14 14:15 -0700
  Re: program which removes comments from C source Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-14 16:30 -0700

csiph-web