博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
学习中 C 相关一些试题和答案
阅读量:4508 次
发布时间:2019-06-08

本文共 1015 字,大约阅读时间需要 3 分钟。

解析用蓝色字体

1. 指针在任何情况下都可进行>, <, >=, <=, = =运算。(错误  )                          指针是无符号数,当它与负数比较时,可能会得到相反的结果

2. switch(c) 语句中c可以是int ,long,char ,float ,unsigned int 类型。    (F)                  错,不能用实形

3.#define print(x)   printf("the no, "#x",is ")。      (T)                             

在主函数中出现print(x) 就代替这一语句printf(”the no, ”#x”,is ”)  也就是凡是出现print(x) 的地方都用printf(”the no, ”#x”,is ”)这一语句代替    printf(”the no, ”#x”,is ”)这一语句的意思是输出the no, ”#x”,is

4. void getmemory(char **p, int num)

{ *p=(char *) malloc(num);}
void
test(void)
{ char
*str=NULL;
getmemory(&str,100);
strcpy(str,"hello");
printf(str);
}
运行test函数有什么结果?10分
答案:输出hello,但是发生内存泄漏。  new,malloc后没有delete,free

5、设int arr[]={6,7,8,9,10};

int
*ptr=arr;
*(ptr++)+=123;
printf("%d,%d",*ptr,*(++ptr));
答案:8,8。这道题目的意义不大,因为在不同的编译器里printf的参数的方向是不一样的,在vc6.0下是从有到左,这里先*(++ptr)
后*pt,于是结果为8,8

6、不使用库函数,编写函数int strcmp(char *source, char *dest) 相等返回0,不等返回-1;

int strcmp(char *source, char *dest)

{
 while( *source!='\0'&& *dest!='\0'&&(*source==*dest))
 {
  source ++;
  dest++;
 }
 return (*source )-(*dest)? -1:0;
}

 

 

转载于:https://www.cnblogs.com/babysunnie/p/3203954.html

你可能感兴趣的文章
Chessboard POJ - 2446(最大流 || 匹配)
查看>>
Warning: Cannot modify header information原因及解决方案
查看>>
Python ConfigParser模块
查看>>
程序员的学习和积累
查看>>
.net实现支付宝在线支付
查看>>
centos7 swoole 三步搞定全部
查看>>
noip2014day1题解
查看>>
Excel:一些方法的理解
查看>>
【转】在RHEL上升级Python
查看>>
java:环境变量设置
查看>>
Servlet的学习之Response响应对象(3)
查看>>
基础知识回顾——上下文管理器
查看>>
ARM(RISC)和x86(CISC)的技术差异
查看>>
第3章 对象基础
查看>>
文件压缩与解压缩
查看>>
android 搜索自动匹配关键字并且标红
查看>>
Android ViewPager使用详解
查看>>
python爬虫之scrapy的pipeline的使用
查看>>
mysql 1366错误
查看>>
mfc 导出数据保存成excel和txt格式
查看>>