我正在做上一年的C编程考试。我想到了这个:
一个程序(见下文)定义了两个变量x和y。
它产生给定的输出。解释为什么字符“ A”出现在变量x的输出中。
程序:
#include <stdio.h>
main ()
{
char x[6] = "12345\0";
char y[6] = "67890\0";
y[7]='A';
printf("X: %s\n",x);
printf("Y: %s\n",y);
}
Run Code Online (Sandbox Code Playgroud)
程序输出:X:1A345 Y:67890
它有很高的分数(7)。而且我不知道如何详细解释。我的答案是:
char数组(y)仅分配了6个char,因此更改第7个字符将更改堆栈中的第2个字符。
任何帮助将不胜感激!(我只有一年级)
namespace MyProgram
{
public class ParentClass
{
}
public class childClass : ParentClass
{
public int Normal()
{
return 1;
}
}
}
Run Code Online (Sandbox Code Playgroud)
别的地方:
ParentClass parentc = new ParentClass();
parentc.Normal(); //<-- I can't call the function normal!
Run Code Online (Sandbox Code Playgroud)
我需要帮助才能使用它.