69,336
社区成员
发帖
与我相关
我的任务
分享
#define DEST_STR "shanghai"
void print(char* pstr)
{
printf("%s",pstr);
}
//我实验了以下两种方式,都可以正常打印出来,请问哪种方式是对的,更合适?
print(&DEST_STR);
print(DEST_STR);
#include <iostream>
using namespace std;
void print2d(char (* pstr)[3])
{
cout << pstr[0] << endl;
}
void print1d(char (& pstr)[3])
{
cout << pstr << endl;
}
int main()
{
char a[][3] = {{'a','b','\0'}};
print2d(a);
char b[3] = {'a','b','\0'};
print1d(b);
print2d(&b);
return 0;
}
print(DEST_STR);//这个