#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
void f(char **x)
{
(*x)++;
**x = 'a';
}
int main()
{
char str[]="hello";
f(&str);
cout << str << endl;
return 0;
}
請告訴我爲什麼這個節目是給編譯Error.I現在用的是G ++編譯器編譯錯誤,同時通過雙指針在CPP
Error :temp1.cpp:16:8: error: cannot convert ‘char (*)[6]’ to ‘char**’ for
argument ‘1’ to ‘void f(char**)’
數組不是指針。你傳遞一個指向數組的指針。 – chris
你忘了在帖子中包含錯誤信息。 –
char * str代替char str,並在f中得到分段錯誤 –