
readstr function in Lesson 10
void readstr(FILE *f,char *string)
{
do
{
fgets(string, 255, f);
} while ((string[0] == ''/'') || (string[0] == ''\n''));
return;
}
Im using the above function in my code (in borland c++)and call it like readstr(filein1,oneline);
In my first code which is not composed of forms, works.
But when I use this function in my second code which is composed of forms. like;
void __fastcall TForm1::ButSourceTxtClick(TObject *Sender)
{
FILE *filein1;
float xx, yy, zz;
int eno,tno,n1,n2,n3,nno,e1,e2,e3;
char oneline[255];
char oneline1[255];
char oneline2[255];
OpenDialog1->Title = "Select the .txt Source File";
OpenDialog1->FileName = "";
OpenDialog1->Filter = "TXT files (*.txt)|*.TXT";
int i = EditSourceTxt->Text.LastDelimiter("\\");
OpenDialog1->InitialDir = EditSourceTxt->Text.SubString(1,i);
if (OpenDialog1->Execute())
{
EditSourceTxt->Text = OpenDialog1->FileName;
}
ifstream infile(EditSourceTxt->Text.c_str());
if(!infile)
{
Application->MessageBox("Cannot open file", EditSourceTxt->Text.c_str(), MB_OK | MB_ICONEXCLAMATION);
}
filein1 = fopen("EditSourceTxt", "rt");
readstr(filein1,oneline);
sscanf(oneline,"%d\n", &totalnodes);
}
it doesnt work but it can open the source txt file.. can you help me?? I m dealing with this problem for hours

This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement