删除C/C++注释
/********************************************************************
*删除C/C++注释
**********************************************************************/
#include <stdio.h>
//注意
//1.对/****/的处理
//2.要保留双引号之间的内容,如char* test = "/*i am not comment */";
//3.对于单引号中的内容同样保留(不检查程序的语法错误)
//4.对于转义字符的处理(见状态6),如char* test = "string\"string too/*i am not comment"
int noComment(FILE *in,FILE *out)
{
int ch, lastch, state = 0, sq = 0;
while( ( ch = fgetc(in) ) != EOF )
{
switch(state)
{
case 0:
if( ch == '/' )
{
lastch = '/' ;
state = 1 ;
}
else
{
if( ch == '\'' || ch == '"' )
{
state = 5 ;
if( ch == '\'' )
sq = 1;
}
fputc(ch, out);
&n
相关文档:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include ".\sqlite3_lib\sqlite3.h"
static int _callback_exec(void * notused,int argc, char ** argv, char ** aszColName)
{
int i;
for ( i=0; i<argc; i++ )
......
1. 找错
#define MAX_SRM 256
DSN get_SRM_no()
{
static int SRM_no;
int I;
for(I=0;I<MAX_SRM;I++,SRM_no++)
{
SRM_no %= MAX_SRM;
......
这个提法有点怪异,但还是常常出现:
char *p = "abcd";
和
string str = "abcdefg";
第一个叫做C风格的字符串,原因是有null作为结尾; 第二个为C++风格的, 不是以null结尾.
实质上: C风格的字符串是:
char[] pArr = {'a', 'b', 'c', 'd', '\0'};
这样决定了处理方式的不同 ......
extern是C/C++语言中表明函数和全局变量作用范围(可见性)的关键字.
它告诉编译器,其声明的函数和变量可以在本模块或其它模块中使用。
1。对于extern变量来说,仅仅是一个变量的声明,其并不是在定义分配内存空间。如果该变量定义多次,会有连接错误
2。通常,在模块的头文件中对本模块提供给其它模块引用的函数和全局 ......
来CSDN的时候,刚刚接触Python,那时候对Python的嵌入部分很感兴趣,只是一直没有时间来弄清其面纱,因此也一直没有使用嵌入的功能,另一个原因是我还没有真正用Python写过一个正式的有用点的东西,不过,现在回过头来继续看这一部分,发现还是挺简单的。以前想把这部分翻译出来,可是由于时间原因,也没有那精力,所以这里 ......