mirror of
https://github.com/Estom/notes.git
synced 2026-05-12 11:36:49 +08:00
28 lines
433 B
C++
28 lines
433 B
C++
#include <iostream>
|
|
#include <vector>
|
|
using namespace std;
|
|
|
|
// 测试字符串和字符数组的参数传递
|
|
void test1(int *s){
|
|
cout<<*(s)<<endl;
|
|
return;
|
|
}
|
|
void test2(int s[]){
|
|
cout<<*s<<endl;
|
|
return;
|
|
}
|
|
void test3(int s[5]){
|
|
cout<<*s<<endl;
|
|
return;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
int s1[]={1,2,3,4,5,6,7,8};
|
|
int s2[3]={4,5,6};
|
|
int* s3 = new int(999);
|
|
test1(s3);
|
|
test2(s3);
|
|
test3(s3);
|
|
return 0;
|
|
} |