怎么char * (*arr)[2]和char **array[2]彼此不同?如果我char* strings[2]使用函数传递,那么如何从问题的第一部分提到的方式访问元素?还请告诉其他方法来访问指针数组的元素.谢谢.
在查看 MakeFiles 时,我发现当名为 target 的文件存在时,即使不使用 .PHONY,目标也会被构建。但是,当我对另一个目标(即 clean)执行相同操作时,目标不会被构建并说“clean 是最新的”,这是可以的。我只想知道当文件存在于当前目录中时为什么要构建另一个目标。
生成文件:
CC:= gcc
CCFLAGS:=-Wall -Wextra
hello: hellomake.o hellofunc.o
$(CC) $(CCFLAGS) hellomake.c hellofunc.c -o file
hellomake.o : hellomake.c
$(CC) $(CCFLAGS) -c hellomake.c
hellofunc.o : hellofunc.c
$(CC) $(CCFLAGS) -c hellofunc.c
clean:
rm -rf *.o
rm -rf file
Run Code Online (Sandbox Code Playgroud)
我当前的目录有一个与目标名称相同的文件,如“hello”。它应该给出结果为“hello is up-to-date”,但它没有这样做并将输出给出为:make hello
gcc -Wall -Wextra hellomake.c hellofunc.c -o file
Run Code Online (Sandbox Code Playgroud)
请说明当目标不是 .PHONY 并且名为目标的文件已存在于当前目录中时,为什么要构建目标。
我有以下代码,我得到分段错误,因为我的函数指针指向一个函数指针数组,并且在函数指针的增量未指向函数指针数组中的下一个元素之后.
int f2(int);
int f1(int);
int(*fp[2])(int) = {f1,f2};
int f1(int x)
{
return (x+10);
}
int f2(int y)
{
return (y+20);
}
int main() {
int sum = 0;
int (*fp1) (int);
fp1 = fp;
printf("addr of fp1 is %x\n",fp1);
++(fp1);
printf("after increment addr of fp1 is %x\n",fp1);
sum = (*fp1)(sum);
printf("%d \n",sum);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是,当我使用指向函数指针的指针时,如:
int(**fp1)(int); 然后代码工作正常.请告诉:
1-为什么只是函数指针不起作用.
2指向函数的指针,即fp1仅在执行++ fp1时将地址递增1.
3-当我通过fp1 = fp [0]; 那么它也不能同时使用指向函数的指针...以及指向函数的指针.fp和fp [0]指向不同的地址吗?
Please explain the output of below program....
int main()
{
unsigned int i=0,j=0;
char c = 'J';
i = (unsigned int) c;
i|=(unsigned int) (c+1)<<8;
i|= (unsigned int) (c+2) <<16;
i|= (unsigned int) (c+3) <<24;
printf("\n%s",&i);
}
Run Code Online (Sandbox Code Playgroud)
以上程序的输出显示为JKLM请解释原因?