Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

sebnem_a

readstr function in Lesson 10

This topic is 5460 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!