開發平台(Platform): (Ex: Win10, Linux, ...)
Win7(Win10)
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
VC++(VS2013 VS2017)
問題(Question):
各位前輩大家好
小弟最近在學習用C++來讀取CpuID
有在GOOGLE上找到一個範例
範例網址:http://blog.csdn.net/aoshilang2249/article/details/44958907
小弟照著範例執行的時候
出現了錯誤
error LNK2019: 無法解析的外部符號 _main 在函式 ___tmainCRTStartup 中被參考
查了一下發現應該是程式中沒有main()
所以自己加入了
void main()
{
char str1;
printf_s("%d\n", GetCpuByCmd);
printf_s("%f\n", GetCpuByCmd);
printf_s("%c\n", GetCpuByCmd);
printf_s("%s\n", GetCpuByCmd);
printf_s("%e\n", GetCpuByCmd);
printf_s("%u\n", GetCpuByCmd);
printf_s("%o\n", GetCpuByCmd);
printf_s("%x\n", GetCpuByCmd);
printf_s("%p\n\n", GetCpuByCmd);
system("wmic CPU get ProcessorID ");
system("PAUSE");
}
加入後程式就可以執行了
但是結果跟我用
system("wmic CPU get ProcessorID ");
所顯示的CpuID並不相同
輸出圖:http://i.imgur.com/Xmf5YCX.jpg
想請問各位前輩
我該用哪種方式輸出我的結果?
程式碼(Code):(請善用置底文網頁, 記得排版)
.h檔:http://codepad.org/CXZyWe42
.h檔(圖):http://i.imgur.com/BhGCP7s.jpg
.cpp:http://codepad.org/3Mgq8Anz
補充說明(Supplement):
另外小弟有試過用這種方式儲存結果
string str1;
str1 = system("wmic CPU get ProcessorID ");
printf_s("%s",str1);
可是很明顯的,事情不是我這種憨人想的這麼簡單...