Jump to content
  • Advertisement


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


readstr function in Lesson 10

This topic is 5549 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

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!