多项选择测验 [英] Multiple choice quiz
问题描述
对于C语言编写的代码,谁能告诉我哪个是最正确或最合适的答案?
代码1:
Can anyone tell me which one is correct or most appropriate answer for code written in C language?
Code1:
#include<stdio.h>
int main()
{
int i=10, j=20;
const int *ptr = &i;
printf("i = %5X", ptr);
printf("ptr = %d", *ptr);
ptr = &j;
printf("j = %5X", ptr);
printf("ptr = %d", *ptr);
return 0;
}
选择:
A. i = FFE2 ptr = 12 j = FFE4 ptr = 24
B. i = FFE4 ptr = 10 j = FFE2 ptr = 20
C. i = FFE0 ptr = 20 j = FFE1 ptr = 30
D.垃圾价值
代码2:
Choice:
A. i= FFE2 ptr=12 j=FFE4 ptr=24
B. i= FFE4 ptr=10 j=FFE2 ptr=20
C. i= FFE0 ptr=20 j=FFE1 ptr=30
D. Garbage value
Code2:
#include<stdio.h>
int fun(int **ptr);
int main()
{
int i=10;
const int *ptr = &i;
fun(&ptr);
return 0;
}
int fun(int **ptr)
{
int j = 223;
int *temp = &j;
printf("Before changing ptr = %5x\n", *ptr);
const *ptr = temp;
printf("After changing ptr = %5x\n", *ptr);
return 0;
}
以上程序的答案
因为我对C
The answer of above program
Because i dont know much about pointers in C
推荐答案
中的指针了解不多,为什么不(尝试)编译它?
:)
Why don''t you (try to) compile it?
:)
有人可以告诉我哪一个是正确的还是最合适的
Can anybody tell me wich one is correct or most apropriate
blockquote>
正确或最适合什么?您尚未说明代码应执行的操作.
Correct or most appropriate for what? You have not explained what your code is supposed to do.
这篇关于多项选择测验的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!