丟人啦,不定參數還可以。。。

丟人了,學C到現在,竟然不知道,不定參數還可以這樣。。。。。

#include "iostream"
using namespace std;

int fun(int sum,...)
{
	int *temp=∑
	temp++;
	for(int i=0;i<sum;i++)
	{
		cout<<*temp<<" ";
		temp++;
	}
	cout<<endl;
	return 0;
}

int main()
{
	int a=1;
	int b=2;
	int c=3;
	char d='c';
	fun(4,a,b,c,d);
	return 0;
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章