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

ÓÃCдµÄ¶ÁÈ¡´úÂëÐÐÊý¡£

½ñÌìÎÞÊ£¬ÔÚÂÛ̳ÉÏÒ»Ö±¿´Ìù×Ó£¬ºÜÉÙ¶¯ÊÖʵ¼ù£¬½ñÌìÊÔ×ÅдÁËÒ»¸ö¶ÁȡԴ³ÌÐò´úÂëÐÐÊýµÄÀý×Ó£º
ÏÖÔڵĴúÂëÈçÏ£¬¿ÉÄÜ»¹Óв»ÍêÉÆµÄµØ·½£¬ÒÔºóÔٸĽø£º
#include <stdio.h>
#define CHARCOUNT 255
#define CON 6 /*µ¥ÐÐ×¢ÊÍ×îÉÙµÄʱºò*/
int realLength = 0;
/*
* function name: strCount
* function : count line number
* created by : lsl
*/
int strCount(int from, char * str)
{
int length = strlen(str), i = 0;
int realCount = length-2-from;
for(i = length-3; str[i]==' ' || str[i] ==' '; i--)
{
realCount--;
}
realLength = realCount;
return realLength;
}
int main(int argc, char *argv[])
{
FILE *fPtr = fopen("tt.c","r");
char buffer[CHARCOUNT];
int lineCount = 0,i=0,j=0,k=0,bufferLen = 0;
int moutLineComment = 0;
if(NULL == fPtr)
{
printf("file open error!\n");
exit(0);
}
while(NULL != fgets(buffer,CHARCOUNT,fPtr))
{
//Èç¹ûÖ»°üº¬Ò»Éϻسµ begin
if(13 == buffer[0] && 10 == buffer[1])
{
//printf("%x%x\n",buffer[0],buffer[1]);
continue;
}
//Èç¹ûÖ»°üº¬Ò»¸ö»Ø³µ end
else
{
bufferLen = strlen(buffer);//¶ÁÈëÐеij¤¶È ËãÉ϶ÁÈëĩβµÄ \n\r
//ÅжÏÒ»ÐÐΪ¿ÕÐеÄÇé¿ö ´ËÐпÉÄܰüº¬Ðí¶à¿Õ¸ñ tab begin
for(i = 0; 32 == buffer[i] || 9 == buffer[i] || 13 == buffer[i] || 10 == buffer[i]; i++ )
{
if(i == bufferLen)
{
break;
}
}
if(bufferLen == i)
{
continue;
}
//ÅжÏÒ»ÐÐΪ¿ÕÐеÄÇé¿ö end
//ÅжÏ//×¢ÊÍ begin
else if(buffer[i] == '/' && buffer[i+1] == '/')
{
continue;
}
//ÅжÏ//×¢ÊÍ end
//Åж϶àÐÐ×¢ÊÍ begin
else if(buffer[i] == '/' && buffer[i+1] == '*')
{
//**/rin tf("here\n");
if((bufferLen-i)>=CON)
{
int tmpLen = strCount(i,buffer);//Çó³ö´ËÐдÓi¿ªÊ¼³ý×îºóµÄ¿Õ¸ñ¡¢\r\nÖ®ÍâµÄ×Ö·ûÊý
if((tmpLen>=4) && buffer[i+tmpLen-2] == '*' && buffer[i+tmpLen-1] == '/')
{
continue;
}
else
{


Ïà¹ØÎĵµ£º

GNU C library ±Ê¼Ç1

ÄÚÈÝ£ºIntroduction ºÍ Error Reporting
1. glibc ËùʵÏÖÈ«²¿»ò²¿·Ö¹æ·¶ÏµĹ¦ÄÜÓÐ
ISO C: The international standard for the C programming language.
POSIX: The ISO/IEC 9945 (aka IEEE 1003) standards for operating systems.
Berkeley Unix: BSD and SunOS.
SVID: The System V Interface Description.
X ......

extern "C"Ïê½â

 Ê±³£ÔÚcppµÄ´úÂëÖ®Öп´µ½ÕâÑùµÄ´úÂë: 
#ifdef __cplusplus 
extern "C" { 
#endif 
//Ò»¶Î´úÂë 
#ifdef __cplusplus 

#endif 
¡¡¡¡ÕâÑùµÄ´úÂëµ½µ×ÊÇʲôÒâË¼ÄØ£¿Ê×ÏÈ£¬__cplusplusÊÇcppÖеÄ×Ô¶¨Òåºê£¬ÄÇô¶¨ÒåÁËÕâ¸öºêµÄ»°±íʾÕâÊÇÒ ......

C/C++——С±à̸CÓïÑÔº¯ÊýÄÇЩÊÂ(7)

C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæÐ¡±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1.       fgetcº¯Êý
fgetcº¯ÊýµÄ¹¦ÄÜÊÇ´ÓÁ÷ÖжÁÈ¡×Ö·û£¬ÆäÓ÷¨ÊÇ£ºint fgetc(FILE *stream); ³ÌÐòÀý×ÓÈçÏ£º
#include <string.h ......

³ÌÐò¸ßÊֱضÁ£ºÐ´ºÃC³ÌÐòµÄ10ÌõÃØ¼®

 ¡¡¡¡ÉñºõÆä¼¼£¬Î©C³ÌÐò£¬¹¦µ½×Գɣ¬Ê®´ó½¨Ò飡
¡¡¡¡1¡¢ÈêӦƵ·±´ß¶¯lint¹¤¾ß£¬¾ÝÆäÓï·¨ÉùÃ÷ÐÞϰÄÚÁ¦£¬´ËʽÔÒòlint֮˼ÂǾö¶ÏʵԶÔÚ¾ýÉÏ¡£
¡¡¡¡
¡¡¡¡2¡¢²»¿ÉÒÀËæNULLÖ¸Õ룬ÈçÈô²»È»£¬»ìãç³Õµß±ØÙ¹¾ýÓڱ˰¶¡£
¡¡¡¡
¡¡¡¡3¡¢×ÝÓÐÌ츳´óÖǻۣ¬ÖªÏþÆäÊÂÎÞ°­£¬ÈêÒ൱¾¡ÊýÇ¿ÖÆÅ²ÒÆº¯Êý²ÎÊýΪԭÐÍËùÆÚÖ®Êý¾ÝÀàÐÍ£¬ÒÔÃâÒ» ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ