Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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++ÖÐ ºê¶¨Òå×Ö·û´® ²Ù×÷

¹ØÓڼǺÅÕ³Ìù²Ù×÷·û(token paste operator): ##
1. ¼òµ¥µÄ˵£¬“##”ÊÇÒ»ÖÖ·Ö¸ôÁ¬½Ó·½Ê½£¬ËüµÄ×÷ÓÃÊÇÏÈ·Ö¸ô£¬È»ºó½øÐÐÇ¿ÖÆÁ¬½Ó¡£
   ÆäÖУ¬·Ö¸ôµÄ×÷ÓÃÀàËÆÓÚ¿Õ¸ñ¡£ÎÒÃÇÖªµÀÔÚÆÕͨµÄºê¶¨ÒåÖУ¬Ô¤´¦ÀíÆ÷Ò»°ã°Ñ¿Õ¸ñ
   ½âÊͳɷֶαêÖ¾£¬¶ÔÓÚÿһ¶ÎºÍÇ°Ãæ±È½Ï£ ......

C\C++ byte»òÕßcharÊý×éתintÖµ

¼ÙÉèÓÐchar a[2];
ÈçÒª°Ñaת»»ÎªintÖµ¡£Ó¦ÊÇÈçÏÂд·¨int b=*(int *)a;
¼´£¬ÏÈ°ÑÖ¸Õëa ת»»ÎªÒ»¸öintÖ¸Õ룬ȻºóÔÙ´Ë»ù´¡ÉÏÈ¡Öµ¡£
µ«ÊÇÁíÒ»ÖÖд·¨ int b=(int)(*a);ÊDz»¶ÔµÄ£¬*a È¡aµÄÄÚ´æµ¥ÔªÄÚÈÝ£¬ÒòΪÏÖÔÚaÊÇcharÖ¸Õ룬ËùÒÔÖ»»áÈ¡a[1]ÖÐÄÚÈÝ£¬×î´óΪ255. ÕâÀïҪ˵Ã÷µÄÊÇ£¬ÔÚ°Ñchar»òbyteÊý×éת»»ÎªÆäËûÀàÐ͵Äֵʱ£¬ÒªÏÈ ......

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³ÌÐòÔ±µÄÇéÊé

#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ÓïÑÔÀ©Õ¹Python(Èý)

ÉÏһƪÖÐÎÒÃÇÒѾ­Á˽âÈçºÎÔÚPython³ÌÐòºÍCÄ£¿éÖ®¼ä½øÐÐÖµµÄÏ໥´«µÝ£¬ÏÖÔÚÎÒÃÇÀ´½øÈëʵ×÷½×¶Î£¬¿´¿´ÈçºÎ½«Ò»¸öCÓïÑÔ¿ª·¢µÄ¿ªÔ´mp3±à½âÂë¿âLAME°üװΪһ¸öPythonÏ¿ÉÒÔʹÓõÄÀ©Õ¹Ä£¿é¡£Ê×ÏÈÈ¥http://lame.sourceforge.net/download.phpÏÂÔØLAMEµÄÔ´´úÂ룬ȻºóÇл»µ½rootÓû§±àÒëÔ´´úÂ룬./configure
make
make instal ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ