Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #75252 > unrolled thread

Memorry error?

Started byAlla _ <modelling.data@gmail.com>
First post2015-11-07 05:18 -0800
Last post2015-11-09 10:26 +0000
Articles 19 — 8 participants

Back to article view | Back to comp.lang.c


Contents

  Memorry error? Alla _ <modelling.data@gmail.com> - 2015-11-07 05:18 -0800
    Re: Memorry error? Alla _ <modelling.data@gmail.com> - 2015-11-07 05:19 -0800
    Re: Memorry error? Alla _ <modelling.data@gmail.com> - 2015-11-07 05:27 -0800
    Re: Memorry error? Alla _ <modelling.data@gmail.com> - 2015-11-07 05:30 -0800
      Re: Memorry error? Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-11-07 08:36 -0500
        Re: Memorry error? Alla _ <modelling.data@gmail.com> - 2015-11-07 06:43 -0800
          Re: Memorry error? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-07 17:22 +0000
    Re: Memorry error? "Osmium" <r124c4u102@comcast.net> - 2015-11-07 07:33 -0600
    Re: Memorry error? Alla _ <modelling.data@gmail.com> - 2015-11-07 06:47 -0800
      Re: Memorry error? Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-11-07 10:36 -0500
      Re: Memorry error? Keith Thompson <kst-u@mib.org> - 2015-11-07 13:37 -0800
      Re: Memorry error? Barry Schwarz <schwarzb@dqel.com> - 2015-11-07 16:26 -0800
        Re: Memorry error? Alla _ <modelling.data@gmail.com> - 2015-11-08 23:03 -0800
          Re: Memorry error? Barry Schwarz <schwarzb@dqel.com> - 2015-11-09 01:01 -0800
            Re: Memorry error? Keith Thompson <kst-u@mib.org> - 2015-11-09 08:27 -0800
              Re: Memorry error? raltbos@xs4all.nl (Richard Bos) - 2015-11-17 22:23 +0000
                Re: Memorry error? Keith Thompson <kst-u@mib.org> - 2015-11-17 15:31 -0800
                  Re: Memorry error? raltbos@xs4all.nl (Richard Bos) - 2015-11-19 10:41 +0000
        Re: Memorry error? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2015-11-09 10:26 +0000

#75252 — Memorry error?

FromAlla _ <modelling.data@gmail.com>
Date2015-11-07 05:18 -0800
SubjectMemorry error?
Message-ID<892c6f15-df18-4132-a798-5fed68982edc@googlegroups.com>
Hello!

I shudder to think how much scolding (hopefully friendly one as usual)
I will receive upon posting this thread :))) Forestalling that, I would
like to add that I am running further; the issue that has just popped up
is unexpected, and has not been discussed in any materials I have studied
thus far. Therefore, although I'd love to learn more and more, I am not 
intending to get into too much of technical details on this issue. 

Below is a tiny program that uses a structure. The program compiles, but
when I run it in Terminal it produces the result in the unexpected format, and 
also shows an error message.

The program defines a structure 'student' that contains name and house 
variables. Defined are 3 such structures. The goal is to ask for 
student's name and "house", and then print out the result. Please, ignore
the amount of for loops; it is possible to do the same within one loop, but 
I copy the program from the cs50 source, and these loops are used for 
clarity only. 

Result (name is one line, house is on another + error message):

Student's name: David
Student's house: DC
Student's name: Laura
Student's house: Seattle
Student's name: Kim
Student's house: Boston

David
 is in DC
.
Laura
 is in Seattle
.
Kim
 is in Boston
.
struct-0(511) malloc: *** error for object 0x7fff68dd39f8: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

I did the following to solve this issue (got this from Google search):

in the Breakpoint Navigator (View->Navigators->Show Breakpoint Navigator),
entered malloc_error_break in the Symbol field at "Add Symbolic Breakpoint".

I have no idea what all this means, yet, but it didn't help :)

// Student database
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


#define STUDENTS 3

// structure representing a student
struct student
{
    char name[80];
    char house[80];
};

int main(void)
{
    struct student students[STUDENTS]; 
    /** [STUDENTS] is the size 3 which is value of 
    constant STUDENTS declared by #define STUDENTS 3 **/
   
   /** of course we can use only one bigger for loop, but
   the following three loops demostrate clearily what happens **/ 
    for (int i = 0; i < STUDENTS; i++)
    {
        printf("Student's name: ");
        fgets(students[i].name, sizeof students[i].name, stdin);
        
        printf("Student's house: ");
        fgets(students[i].house, sizeof students[i].house, stdin);
    }
    
    for (int i = 0; i < STUDENTS; i++)
    {
        printf("%s is in %s.\n", students[i].name, students[i].house);
    }
    
    for (int i = 0; i < STUDENTS; i++)
    {
        free(students[i].name);
        free(students[i].house);
    }
    
    return 0;
    
}

Thank you!


[toc] | [next] | [standalone]


#75253

FromAlla _ <modelling.data@gmail.com>
Date2015-11-07 05:19 -0800
Message-ID<338f131d-c3e7-4380-8baa-c23ce258dba4@googlegroups.com>
In reply to#75252
sorry for the typo in the word 'memory' 

[toc] | [prev] | [next] | [standalone]


#75254

FromAlla _ <modelling.data@gmail.com>
Date2015-11-07 05:27 -0800
Message-ID<129480f6-b623-473f-9a3c-f67feebcd1aa@googlegroups.com>
In reply to#75252
I have also done the version that adds the data into csv file (tiny one).
The same error:
1) name and house appear on different lines (as above)
2) struct-1(569) malloc: *** error for object 0x7fff6166b9f8: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

[toc] | [prev] | [next] | [standalone]


#75255

FromAlla _ <modelling.data@gmail.com>
Date2015-11-07 05:30 -0800
Message-ID<cdb29e98-5047-48bd-b005-750c96dff15a@googlegroups.com>
In reply to#75252
I have also done another version that creates a tiny csv file with 
the data. Same output:
1) name and house on different lines, as above
2) struct-1(569) malloc: *** error for object 0x7fff6166b9f8: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

[toc] | [prev] | [next] | [standalone]


#75258

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2015-11-07 08:36 -0500
Message-ID<n1kuko$hr2$1@dont-email.me>
In reply to#75255
On 11/7/2015 8:30 AM, Alla _ wrote:
> I have also done another version that creates a tiny csv file with
> the data. Same output:
> 1) name and house on different lines, as above
> 2) struct-1(569) malloc: *** error for object 0x7fff6166b9f8: pointer being freed was not allocated
> *** set a breakpoint in malloc_error_break to debug
> Abort trap: 6

     The final loop is the problem: It calls free() on the `name'
and `house' elements of each `struct student', but the memory for
these elements was not obtained from malloc() (or its cousins).
You must not free() anything that you didn't malloc().

-- 
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM

[toc] | [prev] | [next] | [standalone]


#75261

FromAlla _ <modelling.data@gmail.com>
Date2015-11-07 06:43 -0800
Message-ID<4f6562dc-f0cb-4bdc-9522-d4eba25ad689@googlegroups.com>
In reply to#75258
Thank you very much! I wonder why then they used free() when 
there is no malloc in the program. Interesting.

[toc] | [prev] | [next] | [standalone]


#75272

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2015-11-07 17:22 +0000
Message-ID<87fv0hu3kk.fsf@bsb.me.uk>
In reply to#75261
Al la _ <modelling.data@gmail.com> writes:

> Thank you very much! I wonder why then they used free() when 
> there is no malloc in the program. Interesting.

Maybe you've mixed up two versions of the program: an early one with
fixed arrays and then a more sophisticated one where the names are
allocated (they'd be char *name and char *house in the struct).  It's
always possible that the course author has simply made a mistake, but
it's a pretty simple one to spot so that seems unlikely.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#75256

From"Osmium" <r124c4u102@comcast.net>
Date2015-11-07 07:33 -0600
Message-ID<da6cskFckduU1@mid.individual.net>
In reply to#75252
"Alla _" > I shudder to think how much scolding (hopefully friendly one as 
usual)
> I will receive upon posting this thread :))) Forestalling that, I would
> like to add that I am running further; the issue that has just popped up
> is unexpected, and has not been discussed in any materials I have studied
> thus far. Therefore, although I'd love to learn more and more, I am not
> intending to get into too much of technical details on this issue.
>
> Below is a tiny program that uses a structure. The program compiles, but
> when I run it in Terminal it produces the result in the unexpected format, 
> and
> also shows an error message.
>
> The program defines a structure 'student' that contains name and house
> variables. Defined are 3 such structures. The goal is to ask for
> student's name and "house", and then print out the result. Please, ignore
> the amount of for loops; it is possible to do the same within one loop, 
> but
> I copy the program from the cs50 source, and these loops are used for
> clarity only.
>
> Result (name is one line, house is on another + error message):
>
> Student's name: David
> Student's house: DC
> Student's name: Laura
> Student's house: Seattle
> Student's name: Kim
> Student's house: Boston
>
> David
> is in DC
> .
> Laura
> is in Seattle
> .
> Kim
> is in Boston
> .
> struct-0(511) malloc: *** error for object 0x7fff68dd39f8: pointer being 
> freed was not allocated
> *** set a breakpoint in malloc_error_break to debug
> Abort trap: 6
>
> I did the following to solve this issue (got this from Google search):
>
> in the Breakpoint Navigator (View->Navigators->Show Breakpoint Navigator),
> entered malloc_error_break in the Symbol field at "Add Symbolic 
> Breakpoint".
>
> I have no idea what all this means, yet, but it didn't help :)
>
> // Student database
> #include <stdio.h>
> #include <string.h>
> #include <stdlib.h>
>
>
> #define STUDENTS 3
>
> // structure representing a student
> struct student
> {
>    char name[80];
>    char house[80];
> };
>
> int main(void)
> {
>    struct student students[STUDENTS];
>    /** [STUDENTS] is the size 3 which is value of
>    constant STUDENTS declared by #define STUDENTS 3 **/
>
>   /** of course we can use only one bigger for loop, but
>   the following three loops demostrate clearily what happens **/
>    for (int i = 0; i < STUDENTS; i++)
>    {
>        printf("Student's name: ");
>        fgets(students[i].name, sizeof students[i].name, stdin);
>
>        printf("Student's house: ");
>        fgets(students[i].house, sizeof students[i].house, stdin);
>    }
>
>    for (int i = 0; i < STUDENTS; i++)
>    {
>        printf("%s is in %s.\n", students[i].name, students[i].house);
>    }
>
>    for (int i = 0; i < STUDENTS; i++)
>    {
>        free(students[i].name);
>        free(students[i].house);
>    }
>
>    return 0;
>
> }

free pairs with malloc (and others), you didn't use malloc  So the array is 
on the stack, it will automatically be freed. Just take the free stuff out 
and throw it away. 

[toc] | [prev] | [next] | [standalone]


#75262

FromAlla _ <modelling.data@gmail.com>
Date2015-11-07 06:47 -0800
Message-ID<a3ba5a3a-fe62-43f1-87bc-5d0df2dd2882@googlegroups.com>
In reply to#75252
Most likely, they used free() because they have the so called 
GetString ()function which plays the role of scanf and fgets, and 
returns the address of the string (as scanf does, if I understood it 
correctly). 
I use fgets. Doesn't it allocate a memory for the string it gets from
a user?

[toc] | [prev] | [next] | [standalone]


#75264

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2015-11-07 10:36 -0500
Message-ID<n1l5me$cqa$1@dont-email.me>
In reply to#75262
On 11/7/2015 9:47 AM, Alla _ wrote:
> Most likely, they used free() because they have the so called
> GetString ()function which plays the role of scanf and fgets, and
> returns the address of the string (as scanf does, if I understood it
> correctly).
> I use fgets. Doesn't it allocate a memory for the string it gets from
> a user?

     No.  The caller supplies the array, and fgets() fills it.

-- 
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM

[toc] | [prev] | [next] | [standalone]


#75295

FromKeith Thompson <kst-u@mib.org>
Date2015-11-07 13:37 -0800
Message-ID<lnbnb51oft.fsf@kst-u.example.com>
In reply to#75262
Alla _ <modelling.data@gmail.com> writes:
> Most likely, they used free() because they have the so called 
> GetString ()function which plays the role of scanf and fgets, and 
> returns the address of the string (as scanf does, if I understood it 
> correctly). 
> I use fgets. Doesn't it allocate a memory for the string it gets from
> a user?

No.  If fgets allocated memory for the string, you would't have to give
it a pointer to an existing string.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#75318

FromBarry Schwarz <schwarzb@dqel.com>
Date2015-11-07 16:26 -0800
Message-ID<nt4t3bpcailhapqf0p34f06vn1umrma26p@4ax.com>
In reply to#75262
On Sat, 7 Nov 2015 06:47:00 -0800 (PST), Alla _
<modelling.data@gmail.com> wrote:

>Most likely, they used free() because they have the so called 
>GetString ()function which plays the role of scanf and fgets, and 
>returns the address of the string (as scanf does, if I understood it 
>correctly). 
>I use fgets. Doesn't it allocate a memory for the string it gets from
>a user?

You said you copied the program from some cs50 source.  That program
obviously used pointers instead of arrays in the structure.  Why did
you change it?  When you change a program, you are obligated to
determine the full impact of that change

Does their description of GetString document that it allocates memory
dynamically and the caller (that's you) needs to free the memory when
done with it?  

You have used fgets in previous programs.  Did the data it received
from the user ever get placed anywhere but in the array you specified
as the first argument?  Did you ever use the return value from fgets?

Does your description of fgets (You do have a reference or a copy of a
draft standard such as n1570, don't you?) in any way indicate that it
uses memory other than what you passed as arguments?  If you thought
fgets was allocating memory, why did you print the data from the
arrays?

-- 
Remove del for email

[toc] | [prev] | [next] | [standalone]


#75420

FromAlla _ <modelling.data@gmail.com>
Date2015-11-08 23:03 -0800
Message-ID<08a9550d-31e5-4180-a9cf-2d19aa22c42b@googlegroups.com>
In reply to#75318
On Sunday, November 8, 2015 at 4:26:57 AM UTC+4, Barry Schwarz wrote:
> On Sat, 7 Nov 2015 06:47:00 -0800 (PST), Alla _
> <modelling.data@gmail.com> wrote:
> 
> >Most likely, they used free() because they have the so called 
> >GetString ()function which plays the role of scanf and fgets, and 
> >returns the address of the string (as scanf does, if I understood it 
> >correctly). 
> >I use fgets. Doesn't it allocate a memory for the string it gets from
> >a user?
> 
> You said you copied the program from some cs50 source.  That program
> obviously used pointers instead of arrays in the structure.  Why did
> you change it?  When you change a program, you are obligated to
> determine the full impact of that change
> 
> Does their description of GetString document that it allocates memory
> dynamically and the caller (that's you) needs to free the memory when
> done with it?  
> 
> You have used fgets in previous programs.  Did the data it received
> from the user ever get placed anywhere but in the array you specified
> as the first argument?  Did you ever use the return value from fgets?
> 
> Does your description of fgets (You do have a reference or a copy of a
> draft standard such as n1570, don't you?) in any way indicate that it
> uses memory other than what you passed as arguments?  If you thought
> fgets was allocating memory, why did you print the data from the
> arrays?
> 
> -- 
> Remove del for email

I believe I misunderstood that part of the program. Although I have 
not yet read the contents of a function GetString() created by cs50 
staff, I see now that it does allocate memory (unlike fgets and scanf,
which both assign the value they get to variable previously declared); 
in fact, GetString handles all possible issues the student might encounter 
with inputs (like scanf it gets the input from the user, but it aslo handles all pitfalls). 
Therefore, to assign the value received by the user I have to type only

printf ("Enter something");
string s = GetString();

I hope to see the function itself soon.
Anyway, I do not use their functions in my "programs", because I have 
initially decided to learn real C from the beginning, and not to make my 
life seemingly easier by using their appliance and functions - I believe those 
are distracting, and one has to "learn" how to use these artificial functions,
and then eventually figure out how to substitute them for real C functions. 
Not worth it for me; however, it might work for some people. 

[toc] | [prev] | [next] | [standalone]


#75423

FromBarry Schwarz <schwarzb@dqel.com>
Date2015-11-09 01:01 -0800
Message-ID<0gn04bpg79ogvjinagveb5es1qi22i2mod@4ax.com>
In reply to#75420
On Sun, 8 Nov 2015 23:03:18 -0800 (PST), Alla _
<modelling.data@gmail.com> wrote:

>I believe I misunderstood that part of the program. Although I have 
>not yet read the contents of a function GetString() created by cs50 

You should not need to read the actual source of a utility function to
determine how to use it.  (You obviously didn't for printf and scanf.)
There should be something in the documentation provided by the
developer of the function (similar to what the standard provides for
functions in the standard library) that tells you what arguments the
function expects, what changes if any it performs on those arguments,
what it returns, and any special considerations (such as the need to
free memory the function allocates).

>staff, I see now that it does allocate memory (unlike fgets and scanf,
>which both assign the value they get to variable previously declared); 
>in fact, GetString handles all possible issues the student might encounter 
>with inputs (like scanf it gets the input from the user, but it aslo handles all pitfalls). 
>Therefore, to assign the value received by the user I have to type only
>
>printf ("Enter something");
>string s = GetString();

string is not a standard type in C.  Is the function unique to C++?

>I hope to see the function itself soon.
>Anyway, I do not use their functions in my "programs", because I have 
>initially decided to learn real C from the beginning, and not to make my 

That is fine but then you need to be honest with us.  Don't say you
copied their code when in fact you changed it and introduced undefined
behavior.

>life seemingly easier by using their appliance and functions - I believe those 
>are distracting, and one has to "learn" how to use these artificial functions,
>and then eventually figure out how to substitute them for real C functions. 
>Not worth it for me; however, it might work for some people. 

There is nothing intrinsically artificial about non-standard
functions.  There are numerous available libraries that add
functionality not provided by the standard library such as statistical
packages, routines for manipulating matrices, text editors, and spell
checkers.  But the good ones document how to use the functionality
they provide.

-- 
Remove del for email

[toc] | [prev] | [next] | [standalone]


#75458

FromKeith Thompson <kst-u@mib.org>
Date2015-11-09 08:27 -0800
Message-ID<lnd1vjyw7u.fsf@kst-u.example.com>
In reply to#75423
Barry Schwarz <schwarzb@dqel.com> writes:
> On Sun, 8 Nov 2015 23:03:18 -0800 (PST), Alla _
> <modelling.data@gmail.com> wrote:
[...]
>>printf ("Enter something");
>>string s = GetString();
>
> string is not a standard type in C.  Is the function unique to C++?

[...]

I suspect that the same header that declared GetString has:

    typedef char *string;

If so, that's unfortunate, since it encourages the misconception that
strings are "really" pointers.  (A string is by definition "a contiguous
sequence of characters terminated by and including the first null
character"; a char* may or may not be a pointer to a string.)

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#76304

Fromraltbos@xs4all.nl (Richard Bos)
Date2015-11-17 22:23 +0000
Message-ID<564ba747.26087359@news.xs4all.nl>
In reply to#75458
Keith Thompson <kst-u@mib.org> wrote:

> Barry Schwarz <schwarzb@dqel.com> writes:
> > On Sun, 8 Nov 2015 23:03:18 -0800 (PST), Alla _

> >>printf ("Enter something");
> >>string s = GetString();
> >
> > string is not a standard type in C.  Is the function unique to C++?

> I suspect that the same header that declared GetString has:
> 
>     typedef char *string;
> 
> If so, that's unfortunate, since it encourages the misconception that
> strings are "really" pointers.  (A string is by definition "a contiguous
> sequence of characters terminated by and including the first null
> character"; a char* may or may not be a pointer to a string.)

It's equally unfortunate because it pretends that strings are _not_
"really" pointers, but some weird abstract type that might somehow
change from a character sequence accessed by a char *.

Richard

[toc] | [prev] | [next] | [standalone]


#76326

FromKeith Thompson <kst-u@mib.org>
Date2015-11-17 15:31 -0800
Message-ID<lnsi44i4p4.fsf@kst-u.example.com>
In reply to#76304
raltbos@xs4all.nl (Richard Bos) writes:
> Keith Thompson <kst-u@mib.org> wrote:
[...]
>> I suspect that the same header that declared GetString has:
>> 
>>     typedef char *string;
>> 
>> If so, that's unfortunate, since it encourages the misconception that
>> strings are "really" pointers.  (A string is by definition "a contiguous
>> sequence of characters terminated by and including the first null
>> character"; a char* may or may not be a pointer to a string.)
>
> It's equally unfortunate because it pretends that strings are _not_
> "really" pointers, but some weird abstract type that might somehow
> change from a character sequence accessed by a char *.

I don't follow you.  You seem to be implying that strings are "really
pointers", which they most certainly are not.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#76502

Fromraltbos@xs4all.nl (Richard Bos)
Date2015-11-19 10:41 +0000
Message-ID<564da697.4555734@news.xs4all.nl>
In reply to#76326
Keith Thompson <kst-u@mib.org> wrote:

> raltbos@xs4all.nl (Richard Bos) writes:
> > Keith Thompson <kst-u@mib.org> wrote:
> [...]
> >> I suspect that the same header that declared GetString has:
> >> 
> >>     typedef char *string;
> >> 
> >> If so, that's unfortunate, since it encourages the misconception that
> >> strings are "really" pointers.  (A string is by definition "a contiguous
> >> sequence of characters terminated by and including the first null
> >> character"; a char* may or may not be a pointer to a string.)
> >
> > It's equally unfortunate because it pretends that strings are _not_
> > "really" pointers, but some weird abstract type that might somehow
> > change from a character sequence accessed by a char *.
> 
> I don't follow you.  You seem to be implying that strings are "really
> pointers", which they most certainly are not.

No, the string itself is not a pointer. But the object you use to access
that string really _is_ a pointer. My point was that hiding char *
behind a "string" typedef hides _both_ of these facts, that a string is
a set of characters which isn't a pointer, and also that a string is
accessed through a bog-standard char *. 
For a thorough understanding of how C treats strings and char pointers
(and pointers in general, really), it is important to realise that this
works just fine without needing to hide it behind a typedef. So the
typedef is even more unfortunate than you already pointed out.

Richard

[toc] | [prev] | [next] | [standalone]


#75426

FromJorgen Grahn <grahn+nntp@snipabacken.se>
Date2015-11-09 10:26 +0000
Message-ID<slrnn40t7h.5q5.grahn+nntp@frailea.sa.invalid>
In reply to#75318
On Sun, 2015-11-08, Barry Schwarz wrote:
...
> You have used fgets in previous programs.  Did the data it received
> from the user ever get placed anywhere but in the array you specified
> as the first argument?  Did you ever use the return value from fgets?
>
> Does your description of fgets (You do have a reference or a copy of a
> draft standard such as n1570, don't you?) in any way indicate that it
> uses memory other than what you passed as arguments?

Isn't it better to point people to more convenient documentation for
things like these?  On Unix, "man fgets"; on Windows I suppose the
online help ... I don't remember what Alla's environment was.

(I agree of course that people should be taught to read the
documentation, be comfortable doing it, understand that many questions
can be answered there, and so on.)

/Jorgen

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .     .
\X/     snipabacken.se>   O  o   .

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c


csiph-web