打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
09年我曾经遇到的笔试题目
userphoto

2009.10.14

关注
http://www.cppblog.com/expter/archive/2008/12/06/68711.html
1.指针运算
注意 ,每个例子不只是一个题目,可能有多个,用//....................................来分开的
# include <iostream>
# include <stdio.h>
using namespace std;
enum string
{
x1,x2,x3=10,x4,x5,
}X;
int main()
{
//测试1
cout << x1 << x5<<endl;
unsigned char *p1;
unsigned long *p2;
p1 = (unsigned char *)0x801000;
p2 = (unsigned long *)0x801000;
printf("%p\n",p1+5);
printf("%p\n",p2+5);
char * t [] = { "abccc","daa","caa"};
char **bb = t;
cout << t[1] <<endl;
cout << sizeof(t)<<endl;
//....................................
int a[5] = {1,2,3,4,5};
cout << *( (int *)(&a+1)-2) <<endl;
int  i=0;
int  j=1;
long *p = NULL;
char *c = NULL;
if(j++ && i++)
p++,c++;
if(i++ || j++)
p++,c++;
cout << i <<" " << j << " " << *p << " " << (long *)c <<endl;
//....................................
int i =1;
int c = (i++) + (i++) + (i++);
cout << c <<" "<< i<<endl;
return 0;
}
2.
# include <iostream>
# include <stdio.h>
using namespace std;
void foo(int k)
{
char tmp[100];
//sprintf(tmp,"%d",k);
printf("%d\n",tmp);
foo(k-1);
}
int main()
{
int  i= 0;
int  x= 0;
int  y= 0;
printf("%d %d %d %d\n",x--,++y,i++,i++);
char tmp[20]="hello\0\t\\\\world";
cout<<tmp<<endl;
cout << sizeof(tmp) << " " <<strlen(tmp)<<" "<< tmp<<endl;
//....................................
char arr[100]  = "hello world";
int  *v = (int *)arr;
v[0] = 0X61626364;
v[1] = 0X41424344;
v[2] = 0X31323334;
v[3] = 0;
cout<<arr<<endl;
//....................................
foo(3);
return 0;
}
# re: 09年我曾经遇到的笔试题目 2009-09-24 11:38
p1 = (unsigned char *)0x801000; //char是一字节指针
p2 = (unsigned long *)0x801000; //unsigned long是四字节
//5*4=20
(#)
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
suningin详解笔试面试题(6)--moto笔试
suningin详解面试笔试题(11)
285-304
【源码】【wav音频解析】之wavread的C 实现
如何理解数组作为函数参数时,数组名就是指针?
c 任意进制转换正确例题
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服