K&R2 1-23

From: Merrill & Michele (beckjensen_at_comcast.net)
Date: 12/06/04


Date: Mon, 6 Dec 2004 12:05:48 -0600

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



Relevant Pages

  • Help in Java swings(internal Frame)
    ... public int getSize() ... public void valueChanged{ ... private JScrollPane scrollPane1; ... public class PeakContainer extends JInternalFrame ...
    (comp.lang.java.programmer)
  • [PATCH] get rid if __cpuinit and __cpuexit
    ... unsigned long action, void *hcpu) ... unsigned int cpu = hcpu; ... -static int __cpuinit ... __cpu_up(unsigned int cpu) ...
    (Linux-Kernel)
  • [PATCH,RFC 2.6.14 09/15] KGDB: SuperH-specific changes
    ... This adds basic support for KGDB on SuperH as well as adding some architecture ... -static int kgdb_uart_getchar ... -static void kgdb_uart_putchar ... * The command-line option can include a serial port specification ...
    (Linux-Kernel)
  • problem in java swings
    ... public int getSize() ... public void valueChanged{ ... private JScrollPane scrollPane1; ... public class PeakContainer extends JInternalFrame ...
    (comp.lang.java.programmer)
  • ToolTips in a View and TTN_NEEDTEXT
    ... extern int g_minWorkPeriod; ... void CDayView::CreateAllFonts ... void CDayView::DrawDayLog(CDC* pDC) ... BOOL CDayView::TimeToY ...
    (microsoft.public.vc.mfc)