我的作業是 form listBox openlistdiolog 也就是開檔讀檔
讀的是這個 他是.txt檔 我用的是visual C++ 2010 Exp
1234455
901065741
231
45689211963569
55289
10568944652
52123554
456221289
12355897
5246465132.1
這是我的程式
#include "stdafx.h";
#include "Form1.h";
#include <vcclr.h>;
using namespace System::Runtime::InteropServices;
float Blood_Pressure[100];
float ECG[100];
int datalength;
float xx;
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
String ^temp; String ^Ctemp; String ^Str;
orrno_t err;
int len; int Index;
FILE *fp; char *printout; int i;
float tempecg, tempbp; printout= new char [500];
openFileDialog^ openFileDialog = gcnew openFileDialog;// openFileDialog 變數名稱
openFileDialog1->InitialDirectory = "c:\\";
openFileDialog1->FilterInder = "txt files (*.txt)|*.txt|All files(*.*)|*.*";
openFileDialog1->FilterInder = 2;
openFileDialog1->RestoreDirectory = true;
if ( openFileDialogl->ShowDialog() == System::Windows::Forms::DialogResult::OK){
if (( openFileDialogl->openFile() )!= nullptr){
temp = openFileDialogl->FileName;
char* filename = (char*) Marshal::StringToHGlbalAnsi(temp).ToPointer(); i =0;
if (( err = fopen_s(&fp,filename,"rt"))==0) { //rt->read text 可看指令碼
for(int i=1;i<<11;i++){//讀十個檔案
fscanf_s(fp, " %f %f " , &tempecp, &tempbp);
sprintf_s(printout, 1500, "%d\t\t %4.4f \t\t %4.4f \n", i , tempecg , tempbp ); // 變成文字列到listbox
Ctemp = gcnew String( printout );
listBox1-> Items-> Add(Ctemp);
delete Ctemp;
Blood_Pressure[i]=tempbp;
ECG[i]=tempecg;
fclose(fp); }
}
}
};
)
偵錯時一直出現
1>------ 已開始建置: 專案: 功課 讀黨, 組態: Debug Win32 ------
1> 功課 讀黨.cpp
1>功課 讀黨.cpp(4): warning C4067: 未預期的語彙基元,接著前置處理器指示詞 - 必須是新行
1>功課 讀黨.cpp(5): warning C4067: 未預期的語彙基元,接著前置處理器指示詞 - 必須是新行
1>C:\Program Files (x86)\Microsoft V
This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.
留言列表