Deprecated: Array and string offset access syntax with curly braces is deprecated in /mnt/hep_web/hep_web/member/n-kota/dokuwiki/inc/init.php on line 542
ja:root:tstring [GiriWiki]

ユーザ用ツール

サイト用ツール


ja:root:tstring

差分

この文書の現在のバージョンと選択したバージョンの差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
ja:root:tstring [2014/04/24 11:55]
kota [その他使い方、関数など色々]
ja:root:tstring [2018/02/06 07:21] (現在)
kota [基本的な使い方]
ライン 9: ライン 9:
   * やり方色々   * やり方色々
 <code c_mac> <code c_mac>
-TString str("​hoge"​); ​ //​ありがち+TString str("​hoge"​);​
  
-TString str = "​hoge"; ​//​こちらもありがち+TString str = "​hoge";​
  
 TString str;          //​まず宣言してから TString str;          //​まず宣言してから
ライン 36: ライン 36:
 cout << str.Data() << endl; cout << str.Data() << endl;
 </​code>​ </​code>​
-  * 上の2つの出力は同じ(hoge)。Data関数の意味?よくわからん+  * 上の2つの出力は同じ(hoge)。TString::Data()は Char_t* を返している。
  
  
ライン 49: ライン 49:
                                        // hoge1.root と出力される                                        // hoge1.root と出力される
  
 + cout << Form("​hoge%02d.root",​1) << ","​ << Form("​hoge%03d.root",​1) << endl;
 +                                       //​フォーマット指定子のリーディングゼロの機能(0詰め)を使うと、
 +                                       //​hoge01.root , hoge001.root と出力される
 </​code>​ </​code>​
  
ライン 56: ライン 59:
       * %f  : float        * %f  : float 
       * %lf : double       * %lf : double
 +      * %c  : char  (1文字)
 +      * %s  : char* , TString (文字列)
 +      * %lld: Long64_t
  
 ---- ----
ライン 64: ライン 70:
   * 同じ名前で生成するとダメ   * 同じ名前で生成するとダメ
 <code c_mac> <code c_mac>
- TH1D *hist[10];                              //​先に10個のヒストグラムを確保 + 
- for (Int_t i = 0 ; i < 10 ; i++){+ const Int_t Nhist = 10; //const がないと次の行でエラーがでる 
 + TH1D *hist[Nhist];                              //​先に10個のヒストグラムを確保 
 + for (Int_t i = 0 ; i < Nhist ; i++){
      ​hist[i] = new TH1D(Form("​hist%d",​i+1)); ​ //​newでそれぞれの名前のヒストグラムを割り当てる      ​hist[i] = new TH1D(Form("​hist%d",​i+1)); ​ //​newでそれぞれの名前のヒストグラムを割り当てる
     }  ​     }  ​
ja/root/tstring.1398340551.txt.gz · 最終更新: 2014/04/24 11:55 by kota