Jump to content
  • Advertisement
Sign in to follow this  
gingsi

please help....(about Visual C++)

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

Hello everyone, I am now writing a program of GUI that can plot graphs of data from a txt file (or dat file). However, I encounter the problem of NullReferenceException. I tried different methods but the problem still exists. Please help to see whether my program has any problem: void readdata() { int i=0; string line; const size_t size = 100; char nstring[size]; ifstream myfile ("0003.txt"); if (myfile.is_open()) { while (!myfile.eof()) { getline(myfile, line, '\n'); strcpy_s(nstring, line.c_str()); strcat_s(nstring, "(char ^)"); data = atof(nstring); i++; } myfile.close(); } else MessageBox::Show(L"File could not be opened"); //I have tried this, it seems also work /* FILE *pFile; fopen_s(&pFile,"0003.txt", "r"); for (int i = 0 ; i < 10 ; i++) fscanf_s(pFile, "%f", data); fclose (pFile); */ } I put the program in: public: Form2(void) { readdata(); InitializeComponent(); // //TODO: Add the constructor code here // } Thank you very much~

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by gingsi
Hello everyone, I am now writing a program of GUI that can plot graphs of data from a txt file (or dat file). However, I encounter the problem of NullReferenceException.


There is no such language as "Visual C++", and no such thing in C++ as a NullReferenceException (unless you define it yourself). Please first make sure you are compiling things the way you think you are.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!