- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
C基础测试题
1、有数组定义int a[2][2]={{1},{2,3}};则a[0][1]的值为? 答案是({{1},{3}} )
2、请填写以下括号里的值
char str[ ]= Hello;
char *p = str;
int n = 10;
sizeof(str) = ( 5 )
sizeof(p) = ( 5 )
sizeof(n)=( 2 )
void func(char str[100])
{ }
sizeof(str)=( 3 )
3. (选择题)
有以下程序
int fun(int x,int y,int *cp,int *dp)
{ *cp=x+y; *dp=x-y; }
main()
{ int a, b, c, d;
a=30; b=50;
fun(a,b,c,d);
printf(%d,%d, c, d); }
输出结果是 (3)
1. 50,30
2. 30,50
3. 80,-20
4. 80,20
4.Typedef 在C语言中频繁用以声明一个已经存在的数据类型的同义字。也可以用预处理器做类似的事。例如,思考一下下面的例子:
#define dPS struct s *
typedef struct s * tPS;
以上两种情况的意图都是要定义dPS 和 tPS 作为一个指向结构s指针。哪种方法更好呢?(如果有的话)为什么?
。
5、写出char* strcpy(char * strDest,const char * strSrc)函数,问这个函数定义返回值char*,有何意义?
6、问小明写的socketProtocol.h头文件,如下的预处理指令有什么作用
#ifndef _SOCKET_PROTOCOL_H_
#define _SOCKET_PROTOCOL_H_
....
代码
....
#endif //
隐藏代码或使代码有效
7.char* getMyString() {
char a[] = hello, world!;
strcpy(a, hello);
return a;
}
int main(void) {
char *p;
p = getMyString();
printf(p);
return 0;
}
写出printf的运行结果 无结果
8.下面是关于c运行库中函数
struct tm *gmtime(
const time_t *timer
)的说明:
Convert a time value to a structure.
struct tm *gmtime(
const time_t *timer
);
Parameter
timer
Pointer to stored time. The time is represented as seconds elapsed since midnight (00:00:00), January 1, 1970, coordinated universal time (UTC).
Return Value
Return a pointer to a structure of type tm. The fields of the returned structure hold the evaluated value of the timer argument in UTC rather than in local time. Each of the structure fields is of type int, as follows:
tm_sec
Seconds after minute (0 – 59).
tm_min
Minutes after hour (0 – 59).
tm_hour
Hours since midnight (0 – 23).
tm_mday
Day of month (1 – 31).
tm_mon
Month (0 – 11; January = 0).
tm_year
Year (current year minus 1900).
tm_wday
Day of week (0 – 6; Sunday = 0).
tm_yday
Day of year (0 – 365; January 1 = 0).
tm_isdst
Always 0 for gmtime.
Remarks
The gmtime function breaks down the timer value and stores it in a statical
原创力文档


文档评论(0)