Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
soft:c [2020/07/25 08:57] – [Read & write files] Ce Zhang | soft:c [2020/11/05 02:10] (current) – Ce Zhang | ||
---|---|---|---|
Line 1: | Line 1: | ||
=====C++===== | =====C++===== | ||
- | ====Read & write files==== | + | |
+ | ==== 2D array ==== | ||
+ | < | ||
+ | TGraph*** g = new TGraph**[Nfile]; | ||
+ | for(i loop) g[i] = new TGraph*[t[i]-> | ||
+ | for(int j = 0; j< | ||
+ | </ | ||
+ | |||
+ | ====EOF==== | ||
+ | < | ||
+ | <<EOF // | ||
+ | .... | ||
+ | EOF // | ||
+ | |||
+ | // | ||
+ | # cat fileA > fileB | ||
+ | // | ||
+ | # cat << EOF > fileB | ||
+ | // | ||
+ | </ | ||
+ | |||
+ | ====I/O==== | ||
< | < | ||
Line 61: | Line 82: | ||
==> " | ==> " | ||
</ | </ | ||
+ | |||
+ | ====函数指针作为参数==== | ||
+ | < | ||
+ | |||
+ | void DiffusionModel (bool (*GeometryFunction)(double, | ||
+ | bool InsideAerogel(double x, double y, double z); | ||
+ | |||
+ | DiffusionModel( | ||
+ | InsideAerogel | ||
+ | ); | ||
+ | </ | ||
+ | |||
+ | ====char * 转换 (for input arg.)==== | ||
+ | < | ||
+ | //char* to int | ||
+ | |||
+ | int a = stoi(argv[1]); | ||
+ | |||
+ | //char* 转 float/ | ||
+ | float b = stof(argv[2]); | ||
+ | double bb = stod(argv[2]); | ||
+ | |||
+ | //char* 转 string (可以直接转) | ||
+ | string str = argv[3]; | ||
+ | cout << a << endl << b << endl << bb << endl << str << endl; | ||
+ | </ |