All pastes #729679 Raw Edit

Programming Challenge 4

public c v1 · immutable
·published 2007-10-08 06:28 UTC
rendered paste body
#include <stdio.h>#include <string.h>// This is a comment :D/*	This is a four line comment!*/int main( int argc, char * argv[] ){	int LOC = 0, comments = 0, blanks = 0, block = 0;	char * buf;	char * blockStart = "/*";	char * blockEnd = "*/"; 	while( fgets( buf, 81, stdin ) )	{		if( strlen( buf ) == 1 )			blanks++;		else if( buf[ 0 ] == '/' && buf[ 1 ] == '/' )			comments++;		else if( strstr( buf, "\"" ) == NULL 			&& strstr( buf, blockStart ) != NULL )		{			block = 1;		}		else if( strstr( buf, "\"" ) == NULL 			&& strstr( buf, blockEnd ) != NULL )		{			comments++;			block = 0;		}		if( block == 1 )			comments++;		LOC++;	}	printf( "LOC: %i\nESLOC: %i\nComments: %i\nBlanks: %i\n",		LOC, (LOC - comments - blanks), comments, blanks );	return 0;}