第一章 开始
来源:互联网 发布:linux awk getline 编辑:程序博客网 时间:2024/05/16 14:37
- main() 缺省 return 0;
- using namespace std; //告诉编译器要使用在名字空间std中声明的名字
//使用vector对象#include <vector>vector<string> chapter_titles(20);
- 条件提示符#ifndef
#ifndef BOOKSTROE_H#define BOOKSTORE_H//...#endif
若前面没定义BOOKSTORE_H,则执行 int main(){#ifdef DEBUGcout<<"Beginning execution of main()\n";#endif//...}
- 编译器使用-D选项定义预处理器常量:$CC -DDEBUG main.c
- 编译C++时,编译器自动定义__cplusplus
#ifdef __cplusplusextern "C"#endifint min(int, int);
- 编译标准C:__STDC__ 记录已被编译行数:__LINE__ 正在被编译的文件名:__FILE__ __TIME__ __DATE__
- 通用预处理器宏assert(),判断一个必须的前提条件
#include <assert.h>assert(filename !=0);
filename=0则终止程序 - 注释对/*...*/不能嵌套,解决办法:加空格/*... * /
- 未知个数的输入值
#include <iostream>#include <string>int main(){string word;while(cin>>word)cout<<"word read is: "<<word<<'\n';cout<<"ok: no more words to read: bye!\n";return 0;}
- 文件输入和输出
#include <iostream>#include <fstream>#include <sting>int main(){ofstream outfile("out_file");ifstream infile("in_file");if(!infile){cerr<<"error: unable to open input file!\n";return -1;}if(!outfile){cerr<<"error: unable to open output file!\n";return -2;}string word;while (infile>>word)outfile<<word<<' ';return 0;}
根据所定义函数的需求返回不同的值。
0一般表示成功执行
-1一般表示不成功
比如你往数据库里插入一条数据,插入失败的时候你返回-1。
那么当你调用该方法时,返回了-1,你就知道:“哦,这是插入数据失败了”
0 0
- 第一章 开始
- 第一章 开始
- 第一章 开始
- 第一章 开始
- 第一章 开始
- 第一章 开始
- 第一章:开始
- 第一章 开始
- 第一章 开始
- 第一章:开始
- 第一章 开始
- 新博开始第一章
- 菜鸟第一章:开始!
- 红皮书 第一章 开始OPENGL
- 第一章 linux的开始~
- 第一章 开始 《C++ Primer》
- C++ Primer | 第一章 开始
- 八大排序 第一章 【开始】
- 在Makefile中进行宏定义-D
- xcode5编译过的xib 怎么在xcode4.6下打开
- SQL SERVER中的WITH T AS () SELECT * FROM T 的用法
- Android多媒体开发 Pro Android Media 第二章 创建自定义相机应用 2
- Android 禁止使用物理键盘
- 第一章 开始
- 成大事必备9种能力、9种手段、9种心态分享
- 《Mali OpenCL SDK v1.1.0》教程样例之二“程序模板”
- wscript.shell
- Windows 钩子详解以及简单例子(VC6)
- CAP定理
- Can't connect to MySQL server on 'localhost' (10061)解决方案
- Linux常用命令
- 让人震撼惊讶的85句话!