【C++】指针作为函数的参数
2016-01-05 11:36
239 查看
#include"iostream.h" #include"stdio.h" void showmessage(char *p) { cout<<p<<endl; } void main() { //定义字符串数组 char *cp = "大家好,这里是指针作为函数参数的实例。"; showmessage(cp); //定义字符串数组 char str[]="大家好,这里是指针作为函数参数的实例。"; showmessage(str); //直接用字符串作为参数 showmessage("hello world"); }