Problem with writing char array to a textfile

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 2128 Views - Last Post: 03 November 2012 - 06:37 AM Rate Topic: -----

#16 Xupicor  Icon User is offline

  • Nasal Demon
  • member icon

Reputation: 249
  • View blog
  • Posts: 582
  • Joined: 31-May 11

Re: Problem with writing char array to a textfile

Posted 03 November 2012 - 06:34 AM

In NetBeans go to Tools->Options->C/C++ and tell us what compiler you're using (Tools Collection->C++ Compiler). Also post its version (for g++ it's g++ --version) both on Windows and Linux. Are these different versions? What compiler flags did you use when compiling?
Was This Post Helpful? 0
  • +
  • -

#17 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6066
  • View blog
  • Posts: 23,526
  • Joined: 23-August 08

Re: Problem with writing char array to a textfile

Posted 03 November 2012 - 06:37 AM

Because the arrays are global, I believe they should by the standard be initialized to 0 by default. I never rely on this, and always initialize character arrays as follows:

char myArray[32] = { 0 };


which ensures all elements contain the null character.
Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2