Re: K&R2 1-23
From: CBFalconer (cbfalconer_at_yahoo.com)
Date: 12/06/04
- Next message: CBFalconer: "Re: vc.user_comments[i] = string; /*crashing*/"
- Previous message: CBFalconer: "Re: New book - 'C of Peril'"
- In reply to: Merrill & Michele: "K&R2 1-23"
- Next in thread: Merrill & Michele: "Re: K&R2 1-23"
- Reply: Merrill & Michele: "Re: K&R2 1-23"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 06 Dec 2004 21:51:05 GMT
Merrill & Michele wrote:
>
> The exercise is to remove all comments from a source file. What I've
> written so far is:
>
> /* decommentizer: removes this style of comment from source */
> #include <stdio.h>
>
> void strconst(char);
> void quotestr(char);
> void decomment(void);
>
> int main(void)
> {
> int c;
> while((c = getchar())) != EOF)
> {
>
> I'm not sure if I've thought correctly through the cases. For example,
> I'm reasonably certain that the function that handles quoted strings
> will simply putchar() until it hits another " . I've got myself talked
> into the same being the case with character constants. If so, I could
> reduce the number of prototype declarations above and either pass " or
> ' and have the called function do the same thing. My other question is
> what other ISO-conforming, syntactically-legal things can follow a /
> besides an * . I don't believe that / is an answer to this question.
> MPJ
This came up a while ago and I posted my solution. It is also
available on my site as:
<http://cbfalconer.home.att.net/download/uncmntc.zip>
-- Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net) Available for consulting/temporary embedded and systems. <http://cbfalconer.home.att.net> USE worldnet address!
- Next message: CBFalconer: "Re: vc.user_comments[i] = string; /*crashing*/"
- Previous message: CBFalconer: "Re: New book - 'C of Peril'"
- In reply to: Merrill & Michele: "K&R2 1-23"
- Next in thread: Merrill & Michele: "Re: K&R2 1-23"
- Reply: Merrill & Michele: "Re: K&R2 1-23"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|