Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C/C++ ѧϰ±Ê¼Ç[03].È¥µôC·ç¸ñµÄ×¢ÊÍ

ÍøÉÏËÑË÷ÁËÒ»´ó¶ÑÈ¥µô/*ºÍ*/Ö®¼ä×¢Ê͵ĴúÂë,¾ÍÏñ<The C Programming Language>Á·Ï°1-23ÀïÓÐÈË˵µÄÒ»Ñù
´ó²¿·Ö¶¼»á±»ÒÔϵijÌÐòbroken,Õâ¸ö¹¦ÄÜ¿´ÆðÀ´¼òµ¥,ʵ¼ÊÉϺÜÓÐÄѶÈ.ÍøÉÏʵÏֵĴúÂë,³ýÁËÎÒÕÒµ½µÄÒ»¸öÓÃÎļþÖ¸ÕëʵÏÖµÄûÓÐÎÊÌâÍâ,ÆäÓàµÄ¶¼´æÔÚ¸÷ÖÖbug,²»ÐŵĻ°¾ÍÓÃÒÔϵijÌÐò²âÊÔÒ»ÏÂ:-),µ±È»Õâ¸ö³ÌÐòÒ²²»¹»ÍêÉÆ.
»¹ÊÇÓÐÏÞ״̬×Ô¶¯»úʵÏÖÆðÀ´¸üÑϽ÷Ò²ÈÝÒ×Àí½âµÃ¶à:
/* krx123tp.c - a test program to serve as input to krx123*.c
*
* This is a shameless copy of Ben Pfaff's solution, to which I have
* added a few extra statements to further test the candidate programs
* for this exercise. As Ben says, this program already contains lots
* of examples of comments and not-quite-comments. I've just made it
* a little tougher.
*
*/
/* K&R2 1-23: Write a program to remove all comments from a C program.
Don't forget to handle quoted strings and character constants
properly. C comments do not nest.
This solution does not deal with other special cases, such as
trigraphs, line continuation with \, or <> quoting on #include,
since these aren't mentioned up 'til then in K&R2. Perhaps this is
cheating.
Note that this program contains both comments and quoted strings of
text that looks like comments, so running it on itself is a
reasonable test. It also contains examples of a comment that ends
in a star and a comment preceded by a slash. Note that the latter
will break C99 compilers and C89 compilers with // comment
extensions.
Interface: The C source file is read from stdin and the
comment-less output is written to stdout. **/
#include <stdio.h>
int
main(void)
{
/* State machine's current state. */
enum {
PROGRAM,
SLASH,
COMMENT,
STAR,
QUOTE,
LITERAL
} state;
/* If state == QUOTE, then ' or ". Otherwise, undefined. */
int quote;
state = PROGRAM;
for (;;) {
int c = getchar();
if (c == EOF)


Ïà¹ØÎĵµ£º

ÈçºÎÖÕÖ¹Ï̵߳ÄÔËÐУ¨C/C++£©

ÈçºÎÖÕÖ¹Ï̵߳ÄÔËÐУ¨C/C++£©
ÏëÒªÖÕÖ¹Ï̵߳ÄÔËÐУ¬¿ÉÒÔʹÓÃÒÔÏ·½·¨£º
1¡¢Ï̺߳¯Êý·µ»Ø£¨×îºÃʹÓø÷½·¨£©¡£
2¡¢Í¨¹ýµ÷ÓÃExitThreadº¯Êý£¬Ï߳̽«×ÔÐг·Ïû£¨×îºÃ²»Ê¹Óø÷½·¨£©¡£
3¡¢Í¬Ò»¸ö½ø³Ì»òÁíÒ»¸ö½ø³ÌÖеÄÏ̵߳÷ÓÃTerminateThreadº¯Êý£¨Ó¦±ÜÃâʹÓø÷½·¨£©¡£
4¡¢ExitProcessºÍTerminateProcessº¯ÊýÒ²¿ÉÒÔÓÃÀ ......

C³ÌÐòÔ±µÄÇéÊé

#include <stdio.h>
#include <string.h>
int
main(void)
{
char str[] =
"3BVPSq4xF.K?=u#,"
"G'K<MrDnRr7gH%#,"
"XKf<f%G`w^=?C<#,"
"HgU_AnNR?*PDQU#,"
......

c¿âº¯ÊýÏê½â——assert

c¿âº¯ÊýÏê½â——assert
º¯ÊýÃû: assert
¹¦  ÄÜ: ²âÊÔÒ»¸öÌõ¼þ²¢¿ÉÄÜʹ³ÌÐòÖÕÖ¹
Óà ·¨: void assert(int test);
³ÌÐòÀý:
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
struct ITEM {
   int key;
   int value;
};
/* add item to ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ