1:(void *)ptr 和 (*(void**))ptr的结果是否相同?其中ptr为同一个指针
1:(void *)ptr 和 (*(void**))ptr的结果是否相同?其中ptr为同一个指针
1:(void *)ptr 和 (*(void**))ptr的结果是否相同?其中ptr为同一个指针
#i nclude
void testf(int*p)
{
*p+=1;
}
main()
{
int *n,m[2];
n=m;
m[0]=1;
m[1]=8;
testf(n);
printf("Data v alue is %d ",*n);
}
------------------------------
B)
#i nclude
void testf(int**p)
{
*p+=1;
}
main()
{int *n,m[2];
n=m;
m[0]=1;
m[1]=8;
testf(&n);
printf(Data v alue is %d",*n);
}
下面的结果是程序A还是程序B的?
Data v alue is 8
那么另一段程序的结果是什么?
B.android:id="@+id/my_button
C.button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { /* Perform. action on click*/ }});
D.Button myButton = (Button) findViewById(R.id.my_button);
oid onClick(View v) { Intent it = new Intent(MainActivity.this,SecondActivity.class); startActivity(it); } }); 执行结果是:
A.点击Button后,显示启动MainActivity
B.点击Button后,显示启动SecondActivity
C.点击Button后,创建一个隐式的Intent对象
D.点击Button后,创建一个Activity
关键字 volatile 有什么含意 并给出三个不同的例子。
一个定义为volatile 的变量是说这变量可能会被意想不到地改变,这样,编译器就不会去假设这个变量的值了。精确地说就是,优化器在用到这个变量时必须每次都小心地重新读取这个变量的值,而不是使用保存在寄存器里的备份。下
面是volatile 变量的几个例子:
1). 并行设备的硬件寄存器(如:状态寄存器)
2). 一 个 中断 服 务子 程 序中 会 访问 到 的非 自 动变 量 (Non-automatic variables)
3). 多线程应用中被几个任务共享的变量
C 程序员和嵌入式系统程序员的最基本的问题。嵌入式系统程序员经常同硬件、中断、RTOS等等打交道,所用这些都要求volatile 变量。不懂得volatile 内容将会带来灾难。 (嗯,怀疑这否会是这样),我将稍微深究
一下,看一下这家伙是不是直正懂得volatile 完全的重要性。
1). 一个参数既可以是const 还可以是volatile 吗?解释为什么。
2). 一个指针可以是volatile 吗?解释为什么。
3). 下面的函数有什么错误: int square(volatile int *ptr)
{ return *ptr * *ptr;
}
#include<iostream.h >
void main()
{ int a,b,c,d,x;
a=c=0; b=1;d=20;
if(a) d=d-10;
else if(! b)
if(! c) ;
else x=25;
cout<<”d=”<<d<<endl;
cout<<”x=”<<x<<endl;
}
运行结果:
public class Example{
public static void main(String[] args){
int i = 100;
switch(i){
case 100:
System.out.print(i);
case 200:
System.out.print(i);
case 300:
System.out.print(i);
}
}
}
方法抛出一个IOException当且仅当someTestFails()返回值为真时,则下列说法正确的是()。
A、在(1)处添加 IOException e;
B、在(2)处添加 throw e;
C、在(2)处添加throw new IOException();
D、在(3)处添加throw new IOException();
回答下面的问题(6分) (1).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 函数会有什么样的结果?