摘要: You can debug by adding printf statements to a program, but this is clumsy and very time consuming. A debugger like gdb is a much more efficient debugging tool. Adding printf statements in your program is a way that can cosume your more time.If you wanna chanage this situation and scientific way i.. 阅读全文
posted @ 2011-06-21 09:41 Podevor 阅读(106) 评论(0) 推荐(0) 编辑
摘要: //con_insert.cc#include <iostream>#include <list>#include <string>#include <vector>#include <iterator>using namespace std;int main(int argc,char *argv[]){ list<string> strlist; string str; { while(cin >> str && str!=".") strlist.insert(strl 阅读全文
posted @ 2011-06-19 23:53 Podevor 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 我们在编程中可能会经常用到时间,比如取得系统的时间(获取系统的年、月、日、时、分、秒,星期等),或者是隔一段时间去做某事,那么我们就用到一些时间函数。linux下存储时间常见的有两种存储方式,一个是从1970年到现在经过了多少秒,一个是用一个结构来分别存储年月日时分秒的。time_t 这种类型就是用来存储从1970年到现在经过了多少秒,要想更精确一点,可以用结构struct timeval,它精确到微妙。struct timeval{ long tv_sec; /*秒*/ long tv_usec; /*微秒*/};而直接存储年月日的是一个结构:struct tm{ int tm_sec... 阅读全文
posted @ 2011-06-19 21:30 Podevor 阅读(291) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <string>#include <cstring>using namespace std;int main(int argc,char *argv[]){ //string hello = "hello"; char *p = "hello"; cout << p << endl; cout << "print string as old:" << endl; for(int i = 0; i 阅读全文
posted @ 2011-06-19 20:54 Podevor 阅读(202) 评论(0) 推荐(0) 编辑
摘要: strtod > Convert string to doubleatoi > Convert string to intatol > Convert string to long int1、strtoddouble strtod ( const char * str, char ** endptr );Convert string to doubleParses the C string str interpreting its content as a floating point number and returns its value as a double. If 阅读全文
posted @ 2011-06-19 19:16 Podevor 阅读(240) 评论(0) 推荐(0) 编辑
摘要: double atof ( const char * str );Convert string to doubleParses the C string str interpreting its content as a floating point number and returns its value as a double.The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, start 阅读全文
posted @ 2011-06-19 19:10 Podevor 阅读(156) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <string>using namespace std;int main(int argc,char *argv[]){ cout << "Parameter num is :" << argc << endl; cout << "the command is :" << argv[0] << endl; cout << "Parameter list is: "<& 阅读全文
posted @ 2011-06-19 18:57 Podevor 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 若只是查看当前目录下的文件数目(除开.和..文件),使用下面的命令:$find ./ -type f | wc -l若查看当前目录下面的所有文件,含.和..使用如下命令即可:$wc -lps:find command and wc command1、FIND命令NAMEfind - search for files in a directory hierarchySYNOPSISfind [path...] [expression]DESCRIPTIONThis manual page documents the GNU version offind. find searches thedir 阅读全文
posted @ 2011-06-19 18:32 Podevor 阅读(242) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <string>using namespace std;int main(){ string str = ""; //char str[200]; cin >> str; //cin.getline(str,200); int cnt[256]={}; for(int i = 0; i < str.size(); i++) //for(int i =0; i < strlen(str); i++) { cnt[(int)str[i]]++; } for(int i = 0 阅读全文
posted @ 2011-06-19 18:13 Podevor 阅读(339) 评论(0) 推荐(0) 编辑
摘要: #include <fstream>#include <iostream>#include <string>using namespace std;int main(){//从文件file.txt中读出数据(包含空格信息)ifstream in("file.txt",ifstream::app); if(!in){ cout << "open error" << endl; exit(1); } char result1; while(in.get(result1)) cout << 阅读全文
posted @ 2011-06-19 11:35 Podevor 阅读(176) 评论(0) 推荐(0) 编辑