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


Groups > comp.lang.c > #89745

Re: Long Question: What might cause the seg fault?

From John Gordon <gordon@panix.com>
Newsgroups comp.lang.c
Subject Re: Long Question: What might cause the seg fault?
Date 2016-06-22 00:17 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <nkclev$31l$1@reader1.panix.com> (permalink)
References <nkcdmc$usf$1@dont-email.me> <nkci72$c06$1@jstuckle.eternal-september.org>

Show all headers | View raw


In <nkci72$c06$1@jstuckle.eternal-september.org> Jerry Stuckle <jstucklex@attglobal.net> writes:

> fw1[i] <-- This points at fw1[1] (the second element of an array) the
> second time through, but you only allocated enough room for one value.
> The same with the other pointers in your program.

That's what I thought at first too, but the malloc calls look like this:

    if ((fw1 = malloc(nfgraf * sizeof(float))) == NULL)
        printf("malloc error\n");

According to the output nfgraf is 16, so he's allocating enough space
for 16 floats.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Long Question: What might cause the seg fault? bilsch <king621@comcast.net> - 2016-06-21 15:04 -0700
  Re: Long Question: What might cause the seg fault? BartC <bc@freeuk.com> - 2016-06-21 23:51 +0100
    Re: Long Question: What might cause the seg fault? BartC <bc@freeuk.com> - 2016-06-21 23:53 +0100
      Re: Long Question: What might cause the seg fault? bilsch <king621@comcast.net> - 2016-06-22 01:55 -0700
    Re: Long Question: What might cause the seg fault? John Gordon <gordon@panix.com> - 2016-06-22 00:25 +0000
  Re: Long Question: What might cause the seg fault? Jerry Stuckle <jstucklex@attglobal.net> - 2016-06-21 19:22 -0400
    Re: Long Question: What might cause the seg fault? John Gordon <gordon@panix.com> - 2016-06-22 00:17 +0000
  Re: Long Question: What might cause the seg fault? "James R. Kuyper" <jameskuyper@verizon.net> - 2016-06-21 19:35 -0400
    Re: Long Question: What might cause the seg fault? bilsch <king621@comcast.net> - 2016-06-22 03:36 -0700
  Re: Long Question: What might cause the seg fault? John Gordon <gordon@panix.com> - 2016-06-22 00:29 +0000
    Re: Long Question: What might cause the seg fault? bilsch <king621@comcast.net> - 2016-06-22 03:38 -0700
  Re: Long Question: What might cause the seg fault? Barry Schwarz <schwarzb@dqel.com> - 2016-06-21 21:20 -0700

csiph-web