标签:io os ar 使用 sp 文件 数据 on 2014
#include <iomanip>#include <iostream> using namespace std; int main(int args, char *argv[]) { int ivar = 0; int num = 0; label: ivar ++; num += ivar; if(ivar < 10) { goto label; } cout << num << endl; return 0; }
#include <iostream> using namespace std; void OutputInfo(const char* pchData="Stay hungry,Stay foolish.") { cout << pchData << endl; //输出信息 } int main(int argc, int *argv[]) { OutputInfo(); //利用默认值作为函数实际参数 OutputInfo("lasolmi"); //直接传递实际参数 return 0; }
#include <iostream> #include <stdarg.h> using namespace std; void OutputInfo(int num,...) { va_list arguments; va_start(arguments, num); while(num--) { char *pchData = va_arg(arguments,char*); int iData = va_arg(arguments, int); cout << pchData << endl; cout << iData << endl; } va_end(arguments); } int main(int argc, int *argv[]) { OutputInfo(2, "Bejing", 2008, "lasolmi", 2014); return 0; }
#include <iostream> #include <iomanip> using namespace std; int avg(int a, int b); int main(int argc, int *argv[]) { int iWidth, iLength, iResult; iWidth = 10; iLength = 30; int (*pFun)(int, int); //定义函数指针 pFun = avg; iResult = (*pFun)(iWidth,iLength); cout << iResult << endl; return 0; } int avg(int a, int b) { return (a+b)/2; }
#include <iostream> using namespace std; int main(int argc, int *argv[]) { struct PERSONINFO { int index; char name[30]; short age; }*pPersonInfo, pInfo={0,"lasolmi",21}; pPersonInfo = &pInfo; cout << pPersonInfo->index << endl; cout << pPersonInfo->name << endl; cout << pPersonInfo->age << endl; return 0; }
struct PersonInfo { int index; char name[30]; short age; }Person[4] = { {1, "figo", 23}, (2, "ling", 22), (3, "me", 21), (4, "cong", 20) };
union 共用体类型名 { 成员类型 共用体成员名1; 成员类型 共用体成员名2; ... 成员类型 共用体成员名n; };
#include <iostream> using namespace std; int main(int argc, int *argv[]) { enum Weekday {Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday}; int a = 2 , b = 1; Weekday day; day = (Weekday)a; cout << day << endl; day = (Weekday)(a-b); cout << day << endl; day = (Weekday)(Sunday+Wednesday); cout << day << endl; day = (Weekday)5; cout << day << endl; return 0; }
标签:io os ar 使用 sp 文件 数据 on 2014
原文地址:http://blog.csdn.net/lasolmi/article/details/40505955