起因大概是一篇定時關機的實現吧,實際測試之後並不理想就不放鏈結了,但另一點兒收穫是用c語言執行cmd命令,後來又因此接觸了一點兒批處理檔案,最終發現幾條語句很有意思,經過一段時間的摸索,有了如今的將資料表輸出到文字文件。
最終效果圖如下,通過傳入陣列首位址,陣列大小,以及列數,實現以下輸出。
#include /* 用來使用輸出函式 printf sprintf */
#include /* 用來使用資料型別, uint8_t, uint16_t */
#include /* 用來支援cmd命令 */
#include /* 用來使用字串函式 strchr */
#include /* 用來使用malloc free 函式 */
#define debug_output 0
#define array_size 101
const uint16_t motor_ntc_mv_array[array_size] =
;void eliminate_zero(char* arr);
void array_process_to_space(char* temp_array, uint16_t num);
void table_to_txt_file(uint16_t* array, uint16_t num, uint8_t column);
/** * eliminate_zero
* @brief 消除字元陣列',' 後面的 '\0'
* @param arr字元陣列首位址
* @note 每呼叫一次sprintf函式都會有乙個字串結束標誌,為輸出多個資料,必須清除
*/void
eliminate_zero(char* arr)
char *ptr = arr; //不能初始化為null,否則不滿足while的執行條件
char *pts = arr;
while(ptr != null) }
}/**
* array_process_to_space
* @brief 將陣列清為空格,因陣列中的0即'\0',會導致輸出結束
* @param temp_array 引數描述: 陣列首位址
* @param num 引數描述: 陣列大小
*/void
array_process_to_space(char* temp_array, uint16_t num)
} eliminate_zero(temp1);
sprintf(&temp1[((num-1) % column) * 10],"\t%d", array[num - 1]);
sprintf(buffer,"echo %s >>test.txt",temp1); ///< 結束標誌是\0
system(buffer);
system("echo }; >>test.txt");
free(temp1);
free(buffer);
temp1 = null;
buffer = null;
}int main(void)
將文字資料輸出到Excel C 實現
目錄 為什麼要寫這篇 定義程式目標 設計程式之結構框圖 設計程式之功能邏輯 設計程式之 實現 全域性設定 涉及到文字框的操作 選擇excel檔案操作 excel開啟操作 查詢單元格,找到姓名 快遞單號所在列 文字框字串拆分操作 將文字框中拆分的字串放置在excel 的快遞單號列的對應行 excel關...
將文字檔案匯入到Excel資料表中
dim r sub importfromtextfile dim fso as object,sfile as object,blnexist as boolean dim filename as string,i as integer,icol as integer,linetext as str...
C 將DateTable表資料匯出到Excel中
在visual c 中呼叫excel 並不像讀取excel 中的資料那麼容易了,因為在visual c 中呼叫excel 要使用到excel的com元件。以vs2005為例,首先新增引用 在com選項中,新增microsfot excel 11.0 objet library。然後在程式中引入命名空...