C语言高级测试:为C程序员准备的0x10个最佳问题
整个测试遵循以下的约定:
u
假定在所有的程序中必须的头文件都已经被正确包含。
考虑如下的数据类型:
u
char
为
1
个字节
u
int
为
4
个字节
u
long int
为
4
个字节
u
float
为
4
个字节
u
double
为个
8
字节
u
long double
为
8
个字节
u
指针为
4
个字节
1. Consider the following program:
#include<setjmp.h>
static jmp_buf buf;
main()
{
volatile int b;
b =3;
if(setjmp(buf)!=0)
{
printf("%d ", b);
exit(0);
}
b=5;
longjmp(buf , 1);
}
The output for this program is:
(a) 3
(b) 5
(c) 0
(d) None of the above
2. Consider the following program:
main()
{
struct node
{
int a;
int b;
int c;
};
struct node s= { 3, 5,6 };
struct node *pt = &s;
printf("%d" , *(int*)pt);
}
The output for this program is:
(a) 3
(b) 5
(c) 6
(d) 7
3. Consider the following code segment:
int foo ( int x , int n)
{
int val;
val =1;
if (n>0)
{
if (n%2 == 1) val = val *x;
val = val * foo(x*x , n/2);
}
return val;
}
What function of x and n is compute by this code segment?
(a) x^n
(b) x*n
(c) n^x
(d) None of the above
4. Consider the following program:
main()
{
int a[5] = {1,2,3,4,5};
&nbs
相关文档:
数组赋值我总结一下吧也就三种,那char的来举例:
定义的时候直接赋值.
1:char a[20] = "Hello World!";
2: char a[20];
strcpy(a, "Hello World!");
3:char a[20] = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', '!'};
常见错误赋值方式:
1:char a[20];
a = "Hello World ......
C库函数
字符串函数
函数名
函数原型
功能
返回值
包含头文件
strcat
char *strcat(char *st1, char *str2)
把str2连接到str1后面
str1
string.h
strchr
char *strchr(char *str, int ch)
找出str指向的字符串中第一次出现字符串ch的位置
指向该位置的指针,未找到则返回空指针
......
C/C++ development with the Eclipse Platform
Pawel Leszek
摘要:通过本文你将获得如何在Eclipse平台上开发C/C++项目的总体认识。虽然Eclipse主要被用来开发Java项目,但它的框架使得它很容易实现对其他开发语言的支持。在这篇文章里,你将学会如何使用CDT(C/C++ Development Toolkit),一个在Eclipse平台上最 ......
版权申明:以下内容属于作者正在写作的《软件测试实践》一书的内容,未经许可不得用于任何正式出版物中,如果转载请注明出处。
作者:周伟明
代码检视要点
代码检视技能属于开发人员的基本功,能够很大程度地反应出开发人员的能力水平,前面4.4.1节已经讲过提高评审检视的方法。下面以实际的C/C++语言方面的代码来讲解 ......