0
數組首先這裏是,即時通訊試圖去工作 -的Visual C++錯誤讀取文件流,並轉換爲字符
private: System::Void openToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
OpenFileDialog^ dlg = gcnew OpenFileDialog();
dlg->Filter = "Text Files|*.txt";
String^ stream;
if(dlg->ShowDialog()==Windows::Forms::DialogResult::OK)
{
txtOutput->Text = System::IO::File::ReadAllText(dlg->FileName);
char* num = (char*)(void*)Marshal::StringToHGlobalAnsi(stream); //Convert string to array of char
for (int i=0;i<stream->Length;++i) //ERRONEOUS LINE!!
{
num[i] = num[i]^key; //DECRYPT
}
String^ orig_stream = gcnew String(num);
txtOutput->Text = orig_stream;
}
}
我試着去打開它已經被加密的文件中的代碼。程序編譯W/O任何錯誤,但是在運行時它給我的選項下面的錯誤決裂,繼續或中止:
An unhandled exception of type 'System.NullReferenceException' occurred in Project_Targaryen.exe
Additional information: Object reference not set to an instance of an object.
錯誤指向的循環線。 任何幫助表示讚賞!
它看起來像流永遠不會分配一個對象實例。 – DRH 2011-12-29 17:42:41
哦,耶穌基督!基本錯誤!抱歉!!並感謝一噸! – arijeet 2011-12-29 17:58:27