久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <bdo id='YSzbL'></bdo><ul id='YSzbL'></ul>
      <legend id='YSzbL'><style id='YSzbL'><dir id='YSzbL'><q id='YSzbL'></q></dir></style></legend>
      <i id='YSzbL'><tr id='YSzbL'><dt id='YSzbL'><q id='YSzbL'><span id='YSzbL'><b id='YSzbL'><form id='YSzbL'><ins id='YSzbL'></ins><ul id='YSzbL'></ul><sub id='YSzbL'></sub></form><legend id='YSzbL'></legend><bdo id='YSzbL'><pre id='YSzbL'><center id='YSzbL'></center></pre></bdo></b><th id='YSzbL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='YSzbL'><tfoot id='YSzbL'></tfoot><dl id='YSzbL'><fieldset id='YSzbL'></fieldset></dl></div>
      <tfoot id='YSzbL'></tfoot>

    1. <small id='YSzbL'></small><noframes id='YSzbL'>

    2. 將變量名轉換為 C++ 中的字符串

      converting a variable name to a string in C++(將變量名轉換為 C++ 中的字符串)

      <tfoot id='yYENv'></tfoot>

          <i id='yYENv'><tr id='yYENv'><dt id='yYENv'><q id='yYENv'><span id='yYENv'><b id='yYENv'><form id='yYENv'><ins id='yYENv'></ins><ul id='yYENv'></ul><sub id='yYENv'></sub></form><legend id='yYENv'></legend><bdo id='yYENv'><pre id='yYENv'><center id='yYENv'></center></pre></bdo></b><th id='yYENv'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='yYENv'><tfoot id='yYENv'></tfoot><dl id='yYENv'><fieldset id='yYENv'></fieldset></dl></div>

          <small id='yYENv'></small><noframes id='yYENv'>

              <tbody id='yYENv'></tbody>

              <legend id='yYENv'><style id='yYENv'><dir id='yYENv'><q id='yYENv'></q></dir></style></legend>
              • <bdo id='yYENv'></bdo><ul id='yYENv'></ul>

                本文介紹了將變量名轉換為 C++ 中的字符串的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我想將一些數據輸出到文件中.例如假設我有兩個雙精度向量:

                I'd like to output some data to a file. For example assume I have two vectors of doubles:

                vector<double> data1(10);
                vector<double> data2(10); 
                

                是否有一種簡單的方法可以將其輸出到文件中,以便第一行包含標題data1"和data2",然后是實際內容.的功能輸出數據將傳遞各種不同的數組,因此對名稱進行硬編碼標題是不可能的 - 理想情況下我想轉換變量名稱到某個字符串,然后輸出該字符串,后跟向量數組的內容.但是,我不確定如何將變量名 'data1' 轉換為字符串,或者確實如果它可以輕松完成(從閱讀論壇我猜它不能)如果這是不可能的,替代方法可能是使用關聯容器,例如地圖或更簡單的配對"容器.

                is there an easy way to output this to a file so that the first row contains the headings 'data1' and 'data2' followed by the actual contents. The function which outputs the data will be passed various different arrays so hardcoding the name of the heading is not possible - ideally I'd like to convert the variable name to some string and then output that string followed by the contents of the vector array. However, I'm not sure how to convert the variable name 'data1' to a string, or indeed if it can easily be done (from reading the forums my guess is it can't) If this is not possible an alternative might be to use an associative container such as map or perhaps more simply a 'pair' container.

                pair<vector<double>,string> data1(10,'data1');  
                

                歡迎提出任何建議!

                推薦答案

                您可以使用預處理器stringify"# 做您想做的事:

                You can use the preprocessor "stringify" # to do what you want:

                #include <stdio.h>
                
                #define PRINTER(name) printer(#name, (name))
                
                void printer(char *name, int value) {
                    printf("name: %s	value: %d
                ", name, value);
                }
                
                int main (int argc, char* argv[]) {
                    int foo = 0;
                    int bar = 1;
                
                    PRINTER(foo);
                    PRINTER(bar);
                
                    return 0;
                }
                
                
                name: foo   value: 0
                name: bar   value: 1
                

                (對不起,printf,我從來沒有掌握 的竅門.但這應該足夠了.)

                (Sorry for printf, I never got the hang of <iostream>. But this should be enough.)

                這篇關于將變量名轉換為 C++ 中的字符串的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Why do two functions have the same address?(為什么兩個函數的地址相同?)
                Why the initializer of std::function has to be CopyConstructible?(為什么 std::function 的初始化程序必須是可復制構造的?)
                mixing templates with polymorphism(混合模板與多態性)
                When should I use the keyword quot;typenamequot; when using templates(我什么時候應該使用關鍵字“typename?使用模板時)
                Dependent name resolution amp; namespace std / Standard Library(依賴名稱解析命名空間 std/標準庫)
                gcc can compile a variadic template while clang cannot(gcc 可以編譯可變參數模板,而 clang 不能)
                  <bdo id='kCOE2'></bdo><ul id='kCOE2'></ul>

                      <i id='kCOE2'><tr id='kCOE2'><dt id='kCOE2'><q id='kCOE2'><span id='kCOE2'><b id='kCOE2'><form id='kCOE2'><ins id='kCOE2'></ins><ul id='kCOE2'></ul><sub id='kCOE2'></sub></form><legend id='kCOE2'></legend><bdo id='kCOE2'><pre id='kCOE2'><center id='kCOE2'></center></pre></bdo></b><th id='kCOE2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='kCOE2'><tfoot id='kCOE2'></tfoot><dl id='kCOE2'><fieldset id='kCOE2'></fieldset></dl></div>
                      <legend id='kCOE2'><style id='kCOE2'><dir id='kCOE2'><q id='kCOE2'></q></dir></style></legend>

                      <small id='kCOE2'></small><noframes id='kCOE2'>

                      • <tfoot id='kCOE2'></tfoot>
                            <tbody id='kCOE2'></tbody>
                          主站蜘蛛池模板: 9色视频在线 | 国产精品福利网站 | 国产在线视频一区二区 | 欧美8一10sex性hd | 欧美成年黄网站色视频 | 成人性生交a做片 | 日韩天堂av| 日韩精品一区二区三区视频播放 | 亚州精品成人 | 一级欧美黄色片 | 91久久精品日日躁夜夜躁欧美 | 亚州精品天堂中文字幕 | 久久久久久久久久一区二区 | 中文字幕av一区 | 日日操操| 久久精品99久久 | 鸳鸯谱在线观看高清 | 91久久精品一区二区二区 | 中文字幕1区 | 在线不卡视频 | 精品久久久久香蕉网 | 午夜在线| 中文字幕亚洲欧美 | 久久久久亚洲精品国产 | 欧美日韩欧美 | 久久久久国产一级毛片 | 色综合激情 | 成人福利片 | 欧洲尺码日本国产精品 | www.性色 | 精品在线播放 | 日韩有码一区 | 午夜精品久久久 | 欧美日韩国产精品激情在线播放 | 国产xxxx岁13xxxxhd| 国产一区二区三区在线视频 | 国产一区二区在线视频 | 国产一区二区电影网 | 亚洲高清av在线 | 日本不卡高字幕在线2019 | 午夜精品久久久久99蜜 |