http://blog.csdn.net/fovwin/article/details/9796115

1.以下程序片段运行后,输出的结果是:2215053170
printf("%o", 0x12345678);
2.以下程序片段运行后,输出的结果是:3(tip:\0的出现)
char str[]=”abc\001\///n”;
printf("%d", strlen(str));
3.以下程序片段运行后,输出的结果是:%0(tip:?)
int a, b=10;
printf("%%%d",(a/b)*100);
4.以下程序片段运行后,输出的结果是:4(tip:优先级)
int a,sum=0,i=0;
int b[]={1,3,5,6,4,2,0};
while(a=b[i++]!=4)
sum+=a;
printf(“%d”,sum);
5.以下程序片段运行后,输出的结果是:11(tip:优先级)
struct{
int len;
char* str;
} a[]={{10, "abc"},{20, "cdef"}},*p=&a[0];
printf("%d",++p->len);
6.使用typedef定义一个函数指针类型a,函数无参数,返回值为整型。
typedef int (*a)(void);
7.以下程序片段运行后,输出的结果是:32,16,4(tip:3维数组的元素为2维数组)
int a[][2][2]={0,1,2,3,4,5};
printf("%d,%d,%d",sizeof(a),sizeof(a[0]),sizeof(a[0][0][0]));
8.以下程序片段运行后,输出的结果是:164(tip:数组与指针的互换1*9*8+10*9+2)
int a[7][8][9],*ptr,m;
ptr=(int*)a;
for(m=0;m
*ptr=m;
printf("%d",a[1][10][2]);
9.以下程序片段运行后,输出的结果是:2 6 42(tip:变量的作用域)
#include "stdio.h"
int Square(int i) {return i*i;}
int main(void)
{
int i=0;
i=Square(i);
for(;i
{
static int i=1;
i+=Square(i);
printf("%d ",i);
}
return 0;
}
10.signed char 所能表示的最小数与最大数分别由SCHAR_MIN,SCHAR_MAX定义,则以下程序片段运行后的输出结果是:-128,127
printf("%d,%d",SCHAR_MIN,SCHAR_MAX);
11.以下程序片段运行后,输出的结果是:200
int a[200];
printf("%d",sizeof(a)/sizeof(a[100]));
12.宏定义:将整型变量a的第n位取反,其他位不变。取反限定使用异或运算。
#define bit_reverse(a,n) ((a) ^ (1<
13.以下程序片段运行后,输出的结果是:1,-1(tip:逻辑运算)
int m=0,n=0;
if(m++>2 && m++
n++;
else
n--;
printf("%d,%d",m,n);
14.当引用库函数fopen()时,需要包含的头文件是:stdio.h
15.运行C语言编写的程序  copy/B a.txt a.bak时,copy的C程序 int main(int argc, char *argv[])argv[argc]指向的内容是: NULL
16.补齐以下函数:(tip:多一个’\0’的空间)
/* make a duplicate of s */
char *strdup(char *s)
{
char *p;
p=(char*)malloc( strlen(s) + 1 );
if(p!=NULL)
strcpy(p,s);
return p;
}
17.根据函数说明完成以下函数:
/*
* DESCRIPTION
* The strncpy() functions copy at most len characters from src into dst.
* If src is less than len characters long, the remainder of dst is filled with ‘\0’ characters.
* Otherwise, dst is not terminated.
* RETURN VALUES
* The strncpy() functions return dst.
* If strncpy() does not terminate dst with a NULL character,it insteated returns a pointer to 
* dst[n].
* (which does not neccessarilly refer to a valid memory location)
*/
char *strncpy(char *dest,const char *src,size_t n)
{
char *s;
for(s=dest;  n>0  &&*src!='\0';--n)
*s++=*src++;
for(;0
 *s = ‘\0’   ;
return (dest);
}
/*DESCRIPTION
* The strncat() functions append a copy of the null-terminated string append to the end of the 
* null-terminated string s ,then add a terminating '\0'
* The string s must have sufficient space to hold the result
* The strncat() function appends not more than count characters form append, and then adds a terminating '\0'
*RETURN VALUES
* The strcat() and strncat() functions return the pointer s .
*/

char *strncat(char *dest,const char *src,size_t n)
{
char *s=dest;
while(*dest)
dest++;
while(n--!=0&&(*dest++=*src++))
{
if( n == 0 )
*dest='\0';
}
return s;
}
12-25 18:36