摘要: 处理字符串中字符的标准方式 while(*str){ statements str++;}创建并填充字符串char * pstr = new char[n + 1];pstr = '\0';while(n-- > 0) pstr[n] = cPI的表示:C和C++中并没有提供Pi的数学常量表示,但是我们可以使用数学库的三角函数来表示。#include #define PI (4 *... 阅读全文
posted @ 2014-01-17 22:07 而远之 阅读(129) 评论(0) 推荐(0) 编辑
摘要: Type value;while(inFile >> value){ //loop body goes here. }if(inFile.eof()){//terminated with EOF}else if(inFile.fail()){//terminated with mismatch}else{//terminated with some reason unknown} 阅读全文
posted @ 2014-01-17 02:08 而远之 阅读(162) 评论(0) 推荐(0) 编辑
摘要: windows下允许文件名中含有空格。当把文件名中含有空格的文件拖到显示屏上时。系统会自动加上双引号,文件名不含空格的则没有。。fstream对象用含有双引号的文件名打开文件时会失败。所以读取文件名时,一方面要注意不要使用cin >> filename。。。因为这样只能读取一个字符串。含有空格的文件名无法读取完整。另一方面也要注意处理双引号和非法字符、、:*?"| 阅读全文
posted @ 2014-01-17 01:46 而远之 阅读(312) 评论(0) 推荐(0) 编辑