一些常见的c/c++笔试题
1.下面哪种代码风格更好,why?
A . if ('A' == a)
{a++;}
B. if( a == 'A')
{a++;}
答案:A,如果把==错写成=,因为编译器不允许对常量赋值,容易差错。
2.#define MUTI(x) (x*x)
int i=3,j,k;
j = MUTI(i++);
k = MUTI(++i);
问此时j和k的值
答案:j=9;k=49;
3.unsigned int a=4;
int b=-20;
char c;
(a+b>6)?(c=1):(c=0);
c值为?
答案:c=1,因为a+b后值自动转为unsigned int型(两数相加按正数的原码,负数的反码相加)
ps:表达式中有有符号和无符号相加时,所有的操作数都自动转换为无符号类型
相关文档:
继前篇《Import Module》(http://blog.csdn.net/xiadasong007/archive/2009/09/02/4512797.aspx),继续分析嵌入部分基础知识。这次不多说,有什么问题记得多查英文资料,国内的这方面知识少
还是来看代码,写完我就睡觉了~
#include "python/python.h"
#include <iostream>
using namespace std;
int ......
#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++ )
......
Visual Studio包含了4个本机C/C++运行时库和2个用来管理MS.NET的C/C++运行时库。所有这些库都支持多线程编程环境:目前已经没有专门为单线程开发设计的C/C++运行时库了。表6-1对这些库进行了描述:
Libray Name
Description
LibCMt.lib
Statically linked release version of the library.
Lib ......
2.找错题
试题1:
void test1()
{
char string[10];
char* str1 = "0123456789";
strcpy( string, str1 );
}
试题2:
void test2()
{
char string[10], str1[10];
int i;
for(i=0; i<10; i++)
{
str1[i] = 'a';
}
strcpy( string, str1 );
}
试题3:
void te ......
国家、文化和语言规则集称为区域设置,locale.h头文件中定义了区域设置相关的函数。setlocale函数用于设置或返回当前的区域特性,localeconv用于返回当前区域中的数字和货币信息(保存在struct lconv结构实例中)。setlocale的第一个实参指定要改变的区域行为类别,预定义的setlocale类别有:
&n ......