• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: C++ Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++ Problem


  • Subject: Re: C++ Problem
  • From: Shawn Erickson <email@hidden>
  • Date: Wed, 20 Sep 2006 20:10:23 -0700


On Sep 20, 2006, at 7:34 PM, Kevin McEnhill wrote:

   char *buff;

//    int bob;


   ifstream inputfile( argv[1], ios::in );


   while( inputfile )

   {

       inputfile.getline( buff, 256 );

       cout << buff << endl;

   }


//    bob = 5;

//    cout << bob << endl;


   return 0;

}


The "char *buff" is your problem. The getline function expects that you have passed it a pointer to a buffer 256 char in length but you passed it an uninitialized pointer (to some random place.. likely unallocated/invalid memory). 

Review the following...
<http://www.cplusplus.com/ref/iostream/istream/getline.html>

Note this is a C level conceptual issue and not related to the compiler or C++.

-Shawn

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >C++ Problem (From: "Kevin McEnhill" <email@hidden>)

  • Prev by Date: C++ Problem
  • Next by Date: Re: Debug PPC code on MacPro?
  • Previous by thread: C++ Problem
  • Next by thread: GCC, DLLs are accumulated ?
  • Index(es):
    • Date
    • Thread