问题描述
现在,我知道这看起来像是早期查询的重复,但我已经搜索并尝试了所有内容。我无法打印双指针。我有以下代码
Now, I understand this would look like a repeat of earlier queries, but I have searched and tried everything. I am not able to print a double pointer. I have the following code
int main(void)
{
char *line;
char **args;
int status;
do {
//stuff
args = split(&line);
printf(*args);
}
现在一切正常,只是在最后的打印行中,我收到以下错误:
Now it is all executing fine, Just that in the final print line, I am getting the below error:
expected 'const char * __restrict__' but argument is of type 'char ***'
extern int printf (const char *__restrict __format, ...);
现在,我知道为什么我收到这个错误,因为我试图非法打印一些东西。我只是不知道我需要修复到底是什么,如果我需要打印这些双指针,我们该怎么做呢。
谢谢
我尝试过:
我研究过类似的答案,但没有真正解决我的问题,我也尝试阅读关于指针的文献,但函数split()的返回值是一个指针,我不能改变它。
Now, I know why I am getting this error, because I am trying to print something illegally. I just don't know what exactly is it that I need to fix, also, if I ever need to print these double pointers, how do we go about it.
Thanks
What I have tried:
I have researched for similar answers, but nothing really solves my problem, I have also tried to read literature on pointers, but the return value of the function split() is a pointer and I cannot change that.
推荐答案
这篇关于如何在c中打印指针变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!