Re: Segmentation fault when writing to a file once it has reacher
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Re: Segmentation fault when writing to a file once it has reacher




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Re: Segmentation fault when writing to a file once it has reacher  
T.M. Sommers


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-25-06 12:18 PM

Wes wrote:
> On Thu, 19 Oct 2006 13:24:22 -0400, "T.M. Sommers" <tms@nj.net> wrote: 
>
> How do you mean? If I use constant strings I won't be able to change
> them will I?

I meant the numbers specifying the sizes of the arrays.  It is
better to do something like:

const int ARRAY_SIZE = 32;

if you absolutely have to use an array.  But usually you should
be using std::string.

> Also, some of the functions I'm using require char*s
> (most importantly, read and write).

If you need a fixed-size buffer, then an array might be appropriate.
 
>
> Originally, the line was "enc.write(Encrypt(buffer), 32);", giving
> write() its pointer directly from the Encrypt function.  However, the
> problem still existed. Does that still leak memory?  If so, how should
> I rewrite that portion to not leak memory?

It could leak, depending on how it is implemented.  How to fix it
will also depend on the implementation.
 
>
> How do you mean?  What is 'gcount'?

istream::gcount() returns the number of characters read in the
last unformatted read operation.

--
Thomas M. Sommers -- tms@nj.net -- AB2SB






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:03 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register