Вопрос по VC++
КОД:
#pragma once
#include"stdio.h"
void LoadFromFile(char *File,ListBox ^lb)
{char s[300];
FILE *fp;
int i;
i=0;
lb->Items->Clear();
if(!(fp=fopen(File,"r")))
{MessageBox::Show("Ошибка открытия файла", "Приложение",
MessageBoxButtons::OK,MessageBoxIcon::Asterisk);
return;}
while(!feof(fp))
{fgets(s,300,fp);
String ^dd=gcnew String(s);
/* этот способ конвертирования не удаляет последний управляющий символ, который надо elfkbnm^*/
int j=dd->Length-1;
dd=dd->Substring(0,j);
lb->Items->Add(dd);
i++;}}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{this ->Close();
}
private: System::Void listBox1_Click(System::Object^ sender, System::EventArgs^ e)
{this->textBox1->Text=this->listBox1->Items[this->listBox1->SelectedIndex]->ToString();
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
{this->LoadFromFile("c:\\a.txt",this->listBox1);
}
};
}
выдает ОШИБКИ (У) :
1>------Build started: Project: andrew, Configuration: Debug Win32 ------
1>Compiling...
1>andrew.cpp
1>c:\новая папка (2)\andrew\andrew\Form1.h(21) : warning C4996: 'fopen' was declared deprecated
1> C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\stdio.h(234) : see declaration of 'fopen'
1> Message: 'This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>c:\новая папка (2)\andrew\andrew\Form1.h(151) : error C2039: 'LoadFromFile' : is not a member of 'andrew::Form1'
1> c:\новая папка (2)\andrew\andrew\Form1.h(43) : see declaration of 'andrew::Form1'
1>Build log was saved at "file://c:\Новая папка (2)\andrew\andrew\Debug\BuildLog.htm"
1>andrew - 1 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =========
НАПИШИТЕ ПОЖАЛУЙСТА, почему ошибку наводит именно на "error C2039: 'LoadFromFile' : is not a member of 'andrew::Form1'"? не знаю даже как исправить...
у тебя написано:
void LoadFromFile(char *File,ListBox ^lb)
а дальше ты дергаешь
{this->LoadFromFile
какой, к черту, this? у тебя LoadFromFile отдельная функция, а не член класса
Может быть, функция в заголовочном файле не объявлена.
и почему у меня такое ощущение, что одного stdio.h там явно недостаточно?