Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #106814 > unrolled thread
| Started by | acidlategamer@gmail.com |
|---|---|
| First post | 2017-03-23 09:56 -0700 |
| Last post | 2017-03-23 19:02 -0700 |
| Articles | 13 on this page of 213 — 32 participants |
Back to article view | Back to comp.lang.c
My C program does not compile or gives segmentation fault acidlategamer@gmail.com - 2017-03-23 09:56 -0700
Re: My C program does not compile or gives segmentation fault GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-23 18:04 +0100
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-23 17:07 +0000
Re: My C program does not compile or gives segmentation fault acidlategamer@gmail.com - 2017-03-23 10:36 -0700
Re: My C program does not compile or gives segmentation fault acidlategamer@gmail.com - 2017-03-23 10:42 -0700
Re: My C program does not compile or gives segmentation fault GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-23 18:52 +0100
Re: My C program does not compile or gives segmentation fault Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-03-23 12:54 -0600
Re: My C program does not compile or gives segmentation fault GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-24 00:02 +0100
Re: My C program does not compile or gives segmentation fault Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-03-23 17:16 -0600
Re: My C program does not compile or gives segmentation fault GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-24 00:32 +0100
Re: My C program does not compile or gives segmentation fault Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-03-23 11:57 -0600
Re: My C program does not compile or gives segmentation fault acidlategamer@gmail.com - 2017-03-23 11:23 -0700
Re: My C program does not compile or gives segmentation fault Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-03-23 12:53 -0600
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-23 19:00 +0000
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-23 15:59 -0400
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-23 20:40 +0000
Re: My C program does not compile or gives segmentation fault David Brown <david.brown@hesbynett.no> - 2017-03-23 22:06 +0100
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-23 20:43 -0400
Re: My C program does not compile or gives segmentation fault Ian Collins <ian-news@hotmail.com> - 2017-03-24 14:09 +1300
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-23 21:28 -0400
Re: My C program does not compile or gives segmentation fault Ian Collins <ian-news@hotmail.com> - 2017-03-24 14:33 +1300
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-24 09:23 -0400
Re: My C program does not compile or gives segmentation fault Ian Collins <ian-news@hotmail.com> - 2017-03-25 08:39 +1300
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-24 20:40 -0400
Re: My C program does not compile or gives segmentation fault Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-03-23 19:48 -0600
Re: My C program does not compile or gives segmentation fault John Bode <jfbode1029@gmail.com> - 2017-03-24 13:32 -0700
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-24 20:42 -0400
Re: My C program does not compile or gives segmentation fault Tim Rentsch <txr@alumni.caltech.edu> - 2017-04-17 06:30 -0700
Re: My C program does not compile or gives segmentation fault Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-03-23 19:29 -0600
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-24 10:10 +0000
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-24 09:26 -0400
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-24 13:52 +0000
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-24 10:30 -0400
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-24 14:37 +0000
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-24 12:51 -0400
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-24 18:05 +0000
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-24 15:09 -0400
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-24 12:55 -0400
Re: My C program does not compile or gives segmentation fault jameskuyper@verizon.net - 2017-03-24 09:45 -0700
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-24 12:52 -0400
Re: My C program does not compile or gives segmentation fault jameskuyper@verizon.net - 2017-03-24 10:10 -0700
Re: My C program does not compile or gives segmentation fault David Brown <david.brown@hesbynett.no> - 2017-03-24 18:48 +0100
Re: My C program does not compile or gives segmentation fault James Kuyper <jameskuyper@verizon.net> - 2017-03-24 14:04 -0400
Re: My C program does not compile or gives segmentation fault David Brown <david.brown@hesbynett.no> - 2017-03-24 19:16 +0100
Re: My C program does not compile or gives segmentation fault James Kuyper <jameskuyper@verizon.net> - 2017-03-24 15:10 -0400
Re: My C program does not compile or gives segmentation fault James Kuyper <jameskuyper@verizon.net> - 2017-03-24 15:17 -0400
Re: My C program does not compile or gives segmentation fault David Brown <david.brown@hesbynett.no> - 2017-03-25 00:49 +0100
Re: My C program does not compile or gives segmentation fault James Kuyper <jameskuyper@verizon.net> - 2017-03-24 21:10 -0400
Re: My C program does not compile or gives segmentation fault David Brown <david.brown@hesbynett.no> - 2017-03-25 02:37 +0100
Re: My C program does not compile or gives segmentation fault James Kuyper <jameskuyper@verizon.net> - 2017-03-24 21:45 -0400
Re: My C program does not compile or gives segmentation fault Manfred <noname@invalid.add> - 2017-03-25 15:58 +0100
Re: My C program does not compile or gives segmentation fault Keith Thompson <kst-u@mib.org> - 2017-03-24 12:44 -0700
Re: My C program does not compile or gives segmentation fault supercat@casperkitty.com - 2017-03-24 12:07 -0700
Re: My C program does not compile or gives segmentation fault David Brown <david.brown@hesbynett.no> - 2017-03-25 00:54 +0100
Re: My C program does not compile or gives segmentation fault raltbos@xs4all.nl (Richard Bos) - 2017-03-25 10:16 +0000
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-25 12:32 +0000
Re: My C program does not compile or gives segmentation fault David Brown <david.brown@hesbynett.no> - 2017-03-25 15:17 +0100
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-25 16:32 +0000
Re: My C program does not compile or gives segmentation fault Keith Thompson <kst-u@mib.org> - 2017-03-25 10:15 -0700
Re: My C program does not compile or gives segmentation fault "James R. Kuyper" <jameskuyper@verizon.net> - 2017-03-25 14:07 -0400
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-25 18:23 +0000
Re: My C program does not compile or gives segmentation fault Ike Naar <ike@iceland.freeshell.org> - 2017-03-25 18:48 +0000
Re: My C program does not compile or gives segmentation fault Anton Shepelev <anton.txt@gmail.com> - 2017-03-25 23:22 +0300
Re: My C program does not compile or gives segmentation fault Ike Naar <ike@iceland.freeshell.org> - 2017-03-25 20:47 +0000
Re: My C program does not compile or gives segmentation fault Anton Shepelev <anton.txt@gmail.com> - 2017-03-26 15:56 +0300
Re: My C program does not compile or gives segmentation fault Ike Naar <ike@iceland.freeshell.org> - 2017-03-26 18:13 +0000
Re: My C program does not compile or gives segmentation fault David Brown <david.brown@hesbynett.no> - 2017-03-26 17:03 +0200
Re: My C program does not compile or gives segmentation fault Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-25 21:16 +0000
Re: My C program does not compile or gives segmentation fault raltbos@xs4all.nl (Richard Bos) - 2017-03-25 21:28 +0000
Re: My C program does not compile or gives segmentation fault "James R. Kuyper" <jameskuyper@verizon.net> - 2017-03-25 19:16 -0400
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-26 08:53 +0100
Re: My C program does not compile or gives segmentation fault Keith Thompson <kst-u@mib.org> - 2017-03-26 02:39 -0700
Re: My C program does not compile or gives segmentation fault Sjouke Burry <burrynulnulfour@ppllaanneett.nnll> - 2017-03-26 11:54 +0200
Re: My C program does not compile or gives segmentation fault Ian Collins <ian-news@hotmail.com> - 2017-03-26 22:57 +1300
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-27 08:18 +0100
Re: My C program does not compile or gives segmentation fault Ike Naar <ike@iceland.freeshell.org> - 2017-03-26 11:37 +0000
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-27 08:19 +0100
Re: My C program does not compile or gives segmentation fault Ike Naar <ike@iceland.freeshell.org> - 2017-03-27 21:53 +0000
Re: My C program does not compile or gives segmentation fault Keith Thompson <kst-u@mib.org> - 2017-03-27 16:22 -0700
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-27 08:18 +0100
Re: My C program does not compile or gives segmentation fault Keith Thompson <kst-u@mib.org> - 2017-03-27 08:49 -0700
Re: My C program does not compile or gives segmentation fault BartC <bc@freeuk.com> - 2017-03-27 16:57 +0100
Re: My C program does not compile or gives segmentation fault GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-27 18:19 +0200
Re: My C program does not compile or gives segmentation fault BartC <bc@freeuk.com> - 2017-03-27 17:47 +0100
Re: My C program does not compile or gives segmentation fault supercat@casperkitty.com - 2017-03-27 09:27 -0700
Re: My C program does not compile or gives segmentation fault BartC <bc@freeuk.com> - 2017-03-27 17:56 +0100
Re: My C program does not compile or gives segmentation fault asetofsymbols@gmail.com - 2017-04-01 12:42 -0700
Re: My C program does not compile or gives segmentation fault Keith Thompson <kst-u@mib.org> - 2017-03-27 09:36 -0700
Re: My C program does not compile or gives segmentation fault scott@slp53.sl.home (Scott Lurndal) - 2017-03-27 17:51 +0000
Re: My C program does not compile or gives segmentation fault "James R. Kuyper" <jameskuyper@verizon.net> - 2017-03-27 13:59 -0400
Re: My C program does not compile or gives segmentation fault scott@slp53.sl.home (Scott Lurndal) - 2017-03-27 19:00 +0000
Re: My C program does not compile or gives segmentation fault "James R. Kuyper" <jameskuyper@verizon.net> - 2017-03-27 15:13 -0400
Re: My C program does not compile or gives segmentation fault scott@slp53.sl.home (Scott Lurndal) - 2017-03-27 20:05 +0000
Re: My C program does not compile or gives segmentation fault jameskuyper@verizon.net - 2017-03-27 13:14 -0700
Re: My C program does not compile or gives segmentation fault Ike Naar <ike@iceland.freeshell.org> - 2017-03-27 21:28 +0000
Re: My C program does not compile or gives segmentation fault Keith Thompson <kst-u@mib.org> - 2017-03-27 16:21 -0700
Re: My C program does not compile or gives segmentation fault Ian Collins <ian-news@hotmail.com> - 2017-03-28 13:44 +1300
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-28 08:39 +0100
Re: My C program does not compile or gives segmentation fault raltbos@xs4all.nl (Richard Bos) - 2017-04-03 17:36 +0000
Re: My C program does not compile or gives segmentation fault "James R. Kuyper" <jameskuyper@verizon.net> - 2017-04-03 14:02 -0400
Re: My C program does not compile or gives segmentation fault raltbos@xs4all.nl (Richard Bos) - 2017-04-14 11:24 +0000
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-04-14 18:39 +0100
Re: My C program does not compile or gives segmentation fault James Kuyper <jameskuyper@verizon.net> - 2017-04-14 14:38 -0400
Re: My C program does not compile or gives segmentation fault raltbos@xs4all.nl (Richard Bos) - 2017-04-22 21:06 +0000
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-04-23 17:38 +0100
Re: My C program does not compile or gives segmentation fault Ken Brody <kenbrody@spamcop.net> - 2017-04-14 13:54 -0400
Re: My C program does not compile or gives segmentation fault James Kuyper <jameskuyper@verizon.net> - 2017-04-14 14:36 -0400
Re: My C program does not compile or gives segmentation fault Tim Rentsch <txr@alumni.caltech.edu> - 2017-04-16 19:08 -0700
Re: My C program does not compile or gives segmentation fault David Brown <david.brown@hesbynett.no> - 2017-03-26 17:11 +0200
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-27 08:23 +0100
Re: My C program does not compile or gives segmentation fault David Brown <david.brown@hesbynett.no> - 2017-03-27 10:27 +0200
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-27 10:22 +0100
Re: My C program does not compile or gives segmentation fault scott@slp53.sl.home (Scott Lurndal) - 2017-03-27 15:01 +0000
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-27 18:19 +0100
Re: My C program does not compile or gives segmentation fault supercat@casperkitty.com - 2017-03-27 12:37 -0700
Re: My C program does not compile or gives segmentation fault "James R. Kuyper" <jameskuyper@verizon.net> - 2017-03-27 15:40 -0400
Re: My C program does not compile or gives segmentation fault Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-27 21:28 +0100
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-27 22:27 +0100
Re: My C program does not compile or gives segmentation fault Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-27 23:37 +0100
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-28 08:33 +0100
Re: My C program does not compile or gives segmentation fault James Kuyper <jameskuyper@verizon.net> - 2017-03-28 11:21 -0400
Re: My C program does not compile or gives segmentation fault scott@slp53.sl.home (Scott Lurndal) - 2017-03-28 15:38 +0000
Re: My C program does not compile or gives segmentation fault jm.bourguet@gmail.com - 2017-03-28 09:03 -0700
Re: Readabilty of "3 == x" (was: My C program does not compile or gives segmentation fault) Keith Thompson <kst-u@mib.org> - 2017-03-28 09:20 -0700
Re: Readabilty of "3 == x" Richard Heathfield <rjh@cpax.org.uk> - 2017-03-28 18:55 +0100
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-28 18:49 +0100
Re: My C program does not compile or gives segmentation fault "James R. Kuyper" <jameskuyper@verizon.net> - 2017-03-28 14:53 -0400
Re: My C program does not compile or gives segmentation fault Robert Wessel <robertwessel2@yahoo.com> - 2017-03-28 15:19 -0500
Re: My C program does not compile or gives segmentation fault raltbos@xs4all.nl (Richard Bos) - 2017-04-02 12:49 +0000
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-04-03 17:19 +0100
Re: My C program does not compile or gives segmentation fault jacobnavia <jacob@jacob.remcomp.fr> - 2017-04-03 21:44 +0200
Re: My C program does not compile or gives segmentation fault jameskuyper@verizon.net - 2017-04-03 15:05 -0700
Re: My C program does not compile or gives segmentation fault jacobnavia <jacob@jacob.remcomp.fr> - 2017-04-04 01:19 +0200
Re: My C program does not compile or gives segmentation fault Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-04-04 00:49 +0100
Re: My C program does not compile or gives segmentation fault jameskuyper@verizon.net - 2017-04-03 18:22 -0700
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-04-04 06:38 +0100
Re: My C program does not compile or gives segmentation fault Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-29 00:16 +0100
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-29 00:26 +0100
Re: My C program does not compile or gives segmentation fault Alla <vitale.alla@gmail.com> - 2017-03-28 12:34 +0300
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-28 13:28 +0100
Re: My C program does not compile or gives segmentation fault Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-03-28 07:04 -0600
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-28 14:38 +0100
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-28 10:55 -0400
Re: My C program does not compile or gives segmentation fault jadill33@gmail.com - 2017-03-28 07:27 -0700
Re: My C program does not compile or gives segmentation fault Keith Thompson <kst-u@mib.org> - 2017-03-28 07:58 -0700
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-28 16:13 +0100
Re: My C program does not compile or gives segmentation fault Alla <vitale.alla@gmail.com> - 2017-03-28 18:49 +0300
Re: My C program does not compile or gives segmentation fault Keith Thompson <kst-u@mib.org> - 2017-03-28 09:15 -0700
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-28 18:53 +0100
Re: My C program does not compile or gives segmentation fault scott@slp53.sl.home (Scott Lurndal) - 2017-03-28 18:12 +0000
Re: My C program does not compile or gives segmentation fault Keith Thompson <kst-u@mib.org> - 2017-03-28 11:51 -0700
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-28 19:59 +0100
Re: My C program does not compile or gives segmentation fault Alla <vitale.alla@gmail.com> - 2017-03-28 23:11 +0300
Re: My C program does not compile or gives segmentation fault Alla <vitale.alla@gmail.com> - 2017-04-01 17:20 +0300
Re: My C program does not compile or gives segmentation fault supercat@casperkitty.com - 2017-04-01 08:58 -0700
Re: My C program does not compile or gives segmentation fault GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-04-01 18:41 +0200
Re: My C program does not compile or gives segmentation fault Keith Thompson <kst-u@mib.org> - 2017-04-01 11:37 -0700
Re: My C program does not compile or gives segmentation fault Alla <vitale.alla@gmail.com> - 2017-04-02 22:43 +0300
Re: My C program does not compile or gives segmentation fault David Brown <david.brown@hesbynett.no> - 2017-04-03 08:47 +0200
Re: My C program does not compile or gives segmentation fault Tim Rentsch <txr@alumni.caltech.edu> - 2017-04-26 07:58 -0700
Re: My C program does not compile or gives segmentation fault Ike Naar <ike@iceland.freeshell.org> - 2017-03-25 19:35 +0000
Re: My C program does not compile or gives segmentation fault raltbos@xs4all.nl (Richard Bos) - 2017-03-25 21:37 +0000
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-26 08:39 +0100
Re: My C program does not compile or gives segmentation fault raltbos@xs4all.nl (Richard Bos) - 2017-03-25 21:21 +0000
Re: My C program does not compile or gives segmentation fault Les Cargill <lcargill99@comcast.com> - 2017-03-25 16:54 -0500
Re: My C program does not compile or gives segmentation fault raltbos@xs4all.nl (Richard Bos) - 2017-03-25 22:32 +0000
Re: My C program does not compile or gives segmentation fault supercat@casperkitty.com - 2017-03-26 13:46 -0700
Re: My C program does not compile or gives segmentation fault raltbos@xs4all.nl (Richard Bos) - 2017-04-03 17:39 +0000
Re: My C program does not compile or gives segmentation fault supercat@casperkitty.com - 2017-04-03 11:42 -0700
Re: My C program does not compile or gives segmentation fault Keith Thompson <kst-u@mib.org> - 2017-04-03 12:10 -0700
Re: My C program does not compile or gives segmentation fault supercat@casperkitty.com - 2017-04-03 15:22 -0700
Re: My C program does not compile or gives segmentation fault raltbos@xs4all.nl (Richard Bos) - 2017-04-05 11:01 +0000
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-26 08:45 +0100
Re: My C program does not compile or gives segmentation fault Keith Thompson <kst-u@mib.org> - 2017-03-26 02:35 -0700
Re: My C program does not compile or gives segmentation fault David Brown <david.brown@hesbynett.no> - 2017-03-26 17:19 +0200
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-27 08:15 +0100
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-24 15:12 -0400
Re: My C program does not compile or gives segmentation fault Ian Collins <ian-news@hotmail.com> - 2017-03-25 08:41 +1300
Re: My C program does not compile or gives segmentation fault Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-03-24 16:27 -0600
Re: My C program does not compile or gives segmentation fault James Kuyper <jameskuyper@verizon.net> - 2017-03-24 21:36 -0400
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-24 20:44 -0400
Re: My C program does not compile or gives segmentation fault Ian Collins <ian-news@hotmail.com> - 2017-03-25 14:46 +1300
Re: My C program does not compile or gives segmentation fault supercat@casperkitty.com - 2017-03-24 11:24 -0700
Re: My C program does not compile or gives segmentation fault scott@slp53.sl.home (Scott Lurndal) - 2017-03-24 13:52 +0000
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-24 13:55 +0000
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-24 10:31 -0400
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-24 14:39 +0000
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-24 12:54 -0400
Re: My C program does not compile or gives segmentation fault Jorgen Grahn <grahn+nntp@snipabacken.se> - 2017-03-23 21:56 +0000
Re: My C program does not compile or gives segmentation fault Keith Thompson <kst-u@mib.org> - 2017-03-23 15:18 -0700
Re: My C program does not compile or gives segmentation fault Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-03-23 16:39 -0600
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-23 20:42 -0400
Re: My C program does not compile or gives segmentation fault Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-03-23 16:33 -0600
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-23 20:45 -0400
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-24 10:01 +0000
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-24 09:27 -0400
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-24 13:53 +0000
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-24 10:32 -0400
Re: My C program does not compile or gives segmentation fault Richard Heathfield <rjh@cpax.org.uk> - 2017-03-24 14:42 +0000
Re: My C program does not compile or gives segmentation fault Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-24 12:56 -0400
Re: My C program does not compile or gives segmentation fault supercat@casperkitty.com - 2017-03-24 08:45 -0700
Re: My C program does not compile or gives segmentation fault Jorgen Grahn <grahn+nntp@snipabacken.se> - 2017-03-23 21:14 +0000
Re: My C program does not compile or gives segmentation fault Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-03-23 11:52 -0600
Re: My C program does not compile or gives segmentation fault acidlategamer@gmail.com - 2017-03-23 11:03 -0700
Re: My C program does not compile or gives segmentation fault acidlategamer@gmail.com - 2017-03-23 11:14 -0700
Re: My C program does not compile or gives segmentation fault Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-03-23 12:41 -0600
Re: My C program does not compile or gives segmentation fault Keith Thompson <kst-u@mib.org> - 2017-03-23 11:48 -0700
Re: My C program does not compile or gives segmentation fault acidlategamer@gmail.com - 2017-03-23 11:59 -0700
Re: My C program does not compile or gives segmentation fault Keith Thompson <kst-u@mib.org> - 2017-03-23 12:35 -0700
Re: My C program does not compile or gives segmentation fault acidlategamer@gmail.com - 2017-03-23 12:48 -0700
Re: My C program does not compile or gives segmentation fault Keith Thompson <kst-u@mib.org> - 2017-03-23 13:24 -0700
Re: My C program does not compile or gives segmentation fault scott@slp53.sl.home (Scott Lurndal) - 2017-03-23 20:46 +0000
Re: My C program does not compile or gives segmentation fault Barry Schwarz <schwarzb@dqel.com> - 2017-03-23 19:02 -0700
Page 11 of 11 — ← Prev page 1 … 9 10 [11]
| From | supercat@casperkitty.com |
|---|---|
| Date | 2017-03-24 08:45 -0700 |
| Message-ID | <e270fd0f-7aec-44d0-996b-9e3176f56d34@googlegroups.com> |
| In reply to | #106856 |
On Thursday, March 23, 2017 at 5:34:05 PM UTC-5, Joe Pfeiffer wrote: > The version I had above would be (in CERT's example) > > p = malloc(sizeof *p); > > This mitigates their concern about changing the type of p without > updating the malloc() to match. Code which uses "malloc" generally performs other actions to initialize the newly-created storage. There are some cases where it might be possible to change "*p" to a different type without having to adjust other code, but in general code which uses "malloc" will be dependent upon the type being created in ways other than its size. Given code like: p = (fnord*)malloc(sizeof (fnord)); p->wizzle = 3; p->wozzle = 6; the explicit mention of the type within the "malloc" expression makes clear that the code is expecting to create a "fnord" object. If the code had instead been: p = malloc(sizeof *p); p->wizzle = 3; p->wozzle = 6; and the type of "*p" were changed from "fnord" to a "fnoord" which is similar but has an extra field, then the code would create a "fnoord" whose extra field was uninitialized. In some cases that would be acceptable, but I see no reason to blindly expect that it would be. The former pattern would result in the compiler calling the programmer's attention to the code. If the programmer determined that the code would be just as appropriate for type "fnoord" as it had been for "fnord", the programmer could change the types in the malloc and be done with it, but the diagnostic would give a wise programmer a chance to inspect the surrounding code first to ensure that was the *only* change that was necessary. The latter program, by contrast, would not call attention to itself even if attention were required.
[toc] | [prev] | [next] | [standalone]
| From | Jorgen Grahn <grahn+nntp@snipabacken.se> |
|---|---|
| Date | 2017-03-23 21:14 +0000 |
| Message-ID | <slrnod8elc.1jqn.grahn+nntp@frailea.sa.invalid> |
| In reply to | #106835 |
On Thu, 2017-03-23, Joe Pfeiffer wrote:
> acidlategamer@gmail.com writes:
...
>> Also I came across this code on another website
>> http://quiz.geeksforgeeks.org/queue-set-2-linked-list-implementation/
>
> In that code, the declaration of q includes an initialization:
>
> struct Queue *q = createQueue();
>
...
> (Two things I noticed that aren't actually relevant to your question,
> but I'll mention:
>
> Many people would prefer to see
>
> struct Queue *q = (struct Queue*)malloc(sizeof(struct Queue));
>
> replaced with
>
> struct Queue *q = malloc(sizeof *q);
>
> on the grounds that [...]
I agree.
Mentioning another thing: I'd rather not see that malloc() at all. The
nodes in the queue pretty much need to be malloc()ed, but the struct
Queue doesn't have to. I might want to keep it in a struct, an array,
or just as a local variable.
So I'd prefer createQueue() to look like:
struct Queue foo;
initQueue(&foo);
// or
struct Queue bar = createQueue();
// or
struct Queue baz = EMPTY_QUEUE;
I don't want to get the OP stuck in a pattern where everything is
malloc()ed and everything becomes a pointer. Memory management is
tricky enough as it is ...
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
[toc] | [prev] | [next] | [standalone]
| From | Joe Pfeiffer <pfeiffer@cs.nmsu.edu> |
|---|---|
| Date | 2017-03-23 11:52 -0600 |
| Message-ID | <1b60izc23w.fsf@pfeifferfamily.net> |
| In reply to | #106820 |
acidlategamer@gmail.com writes: > > I see example codes where q is never initialised to NULL and a > function is there that says 'createq'. All it do in the function is > just make rear and front to point to NULL. At that moment nothing is > allocated to anyone. Either you're misunderstanding the examples, or they are wrong. Do you have a URL?
[toc] | [prev] | [next] | [standalone]
| From | acidlategamer@gmail.com |
|---|---|
| Date | 2017-03-23 11:03 -0700 |
| Message-ID | <08f2d23e-4308-4676-8d1b-52f93f2fd6df@googlegroups.com> |
| In reply to | #106825 |
On Thursday, March 23, 2017 at 11:22:28 PM UTC+5:30, Joe Pfeiffer wrote: > acidlategamer@gmail.com writes: > > > > I see example codes where q is never initialised to NULL and a > > function is there that says 'createq'. All it do in the function is > > just make rear and front to point to NULL. At that moment nothing is > > allocated to anyone. > > Either you're misunderstanding the examples, or they are wrong. Do you > have a URL? I am reading a book. I have formatted and removed extra code for better readability. http://codepad.org/4IiDVzpT Thanks for your replies.
[toc] | [prev] | [next] | [standalone]
| From | acidlategamer@gmail.com |
|---|---|
| Date | 2017-03-23 11:14 -0700 |
| Message-ID | <e6fa6333-c2c3-4f7f-a683-298e66d30b08@googlegroups.com> |
| In reply to | #106828 |
On Thursday, March 23, 2017 at 11:34:09 PM UTC+5:30, acidla...@gmail.com wrote: > On Thursday, March 23, 2017 at 11:22:28 PM UTC+5:30, Joe Pfeiffer wrote: > > acidlategamer@gmail.com writes: > > > > > > I see example codes where q is never initialised to NULL and a > > > function is there that says 'createq'. All it do in the function is > > > just make rear and front to point to NULL. At that moment nothing is > > > allocated to anyone. > > > > Either you're misunderstanding the examples, or they are wrong. Do you > > have a URL? > > I am reading a book. I have formatted and removed extra code for better readability. > > http://codepad.org/4IiDVzpT > > Thanks for your replies. Book name is data structures using C - Reema Thareja
[toc] | [prev] | [next] | [standalone]
| From | Joe Pfeiffer <pfeiffer@cs.nmsu.edu> |
|---|---|
| Date | 2017-03-23 12:41 -0600 |
| Message-ID | <1bwpbfal9b.fsf@pfeifferfamily.net> |
| In reply to | #106830 |
acidlategamer@gmail.com writes: > On Thursday, March 23, 2017 at 11:34:09 PM UTC+5:30, acidla...@gmail.com wrote: >> On Thursday, March 23, 2017 at 11:22:28 PM UTC+5:30, Joe Pfeiffer wrote: >> > acidlategamer@gmail.com writes: >> > > >> > > I see example codes where q is never initialised to NULL and a >> > > function is there that says 'createq'. All it do in the function is >> > > just make rear and front to point to NULL. At that moment nothing is >> > > allocated to anyone. >> > >> > Either you're misunderstanding the examples, or they are wrong. Do you >> > have a URL? >> >> I am reading a book. I have formatted and removed extra code for better readability. >> >> http://codepad.org/4IiDVzpT >> >> Thanks for your replies. > > Book name is data structures using C - Reema Thareja Since q is external to any functions, it actually is initialized to NULL before the program begins. So in this case, yes, it has been initialized. If it were a local variable, its value would be indeterminate. Down at the bottom of the page, it says: Output: 1 Segmentation fault So, as expected, this example contains an error that causes the program to crash.
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2017-03-23 11:48 -0700 |
| Message-ID | <lnpoh7akyj.fsf@kst-u.example.com> |
| In reply to | #106830 |
acidlategamer@gmail.com writes:
> On Thursday, March 23, 2017 at 11:34:09 PM UTC+5:30, acidla...@gmail.com wrote:
>> On Thursday, March 23, 2017 at 11:22:28 PM UTC+5:30, Joe Pfeiffer wrote:
>> > acidlategamer@gmail.com writes:
>> > >
>> > > I see example codes where q is never initialised to NULL and a
>> > > function is there that says 'createq'. All it do in the function is
>> > > just make rear and front to point to NULL. At that moment nothing is
>> > > allocated to anyone.
>> >
>> > Either you're misunderstanding the examples, or they are wrong. Do you
>> > have a URL?
>>
>> I am reading a book. I have formatted and removed extra code for better readability.
>>
>> http://codepad.org/4IiDVzpT
>>
>> Thanks for your replies.
>
> Book name is data structures using C - Reema Thareja
Either the "extra code" was necessary for correctness, or the code in
the book is incorrect.
At file scope, you have:
struct queue *q;//Here q is not initialized
q is not *explicitly* initialized. It's implicitly initialized to NULL.
Any file-scope and/or static object without an initializer is implicitly
initialized to zero; for a pointer object, that's a null pointer.
int main()
{
int val, option;
create_queue(q);//just called create queue. At this moment nothing such as struct node is created
At this point, q still has its initial null value, so the call is
equivalent to create_queue(NULL). Since function arguments are always
passed by value, this cannot change the value of q.
void create_queue(struct queue *q)
{
q -> rear = NULL;//how this happened without any error??
q -> front = NULL;
}
This dereferences a null pointer, causing undefined behavior.
You were lucky enough to get a segmentation fault, a clear indication
that there's a problem.
--
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]
| From | acidlategamer@gmail.com |
|---|---|
| Date | 2017-03-23 11:59 -0700 |
| Message-ID | <a29c6c77-e0c1-4cb2-b542-00aaa7c36e47@googlegroups.com> |
| In reply to | #106834 |
On Friday, March 24, 2017 at 12:18:14 AM UTC+5:30, Keith Thompson wrote:
> acidlategamer@gmail.com writes:
> > On Thursday, March 23, 2017 at 11:34:09 PM UTC+5:30, acidla...@gmail.com wrote:
> >> On Thursday, March 23, 2017 at 11:22:28 PM UTC+5:30, Joe Pfeiffer wrote:
> >> > acidlategamer@gmail.com writes:
> >> > >
> >> > > I see example codes where q is never initialised to NULL and a
> >> > > function is there that says 'createq'. All it do in the function is
> >> > > just make rear and front to point to NULL. At that moment nothing is
> >> > > allocated to anyone.
> >> >
> >> > Either you're misunderstanding the examples, or they are wrong. Do you
> >> > have a URL?
> >>
> >> I am reading a book. I have formatted and removed extra code for better readability.
> >>
> >> http://codepad.org/4IiDVzpT
> >>
> >> Thanks for your replies.
> >
> > Book name is data structures using C - Reema Thareja
>
> Either the "extra code" was necessary for correctness, or the code in
> the book is incorrect.
>
> At file scope, you have:
>
> struct queue *q;//Here q is not initialized
>
> q is not *explicitly* initialized. It's implicitly initialized to NULL.
> Any file-scope and/or static object without an initializer is implicitly
> initialized to zero; for a pointer object, that's a null pointer.
>
> int main()
> {
> int val, option;
> create_queue(q);//just called create queue. At this moment nothing such as struct node is created
>
> At this point, q still has its initial null value, so the call is
> equivalent to create_queue(NULL). Since function arguments are always
> passed by value, this cannot change the value of q.
>
> void create_queue(struct queue *q)
> {
> q -> rear = NULL;//how this happened without any error??
> q -> front = NULL;
> }
>
> This dereferences a null pointer, causing undefined behavior.
> You were lucky enough to get a segmentation fault, a clear indication
> that there's a problem.
>
> --
> 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"
I can understand now, that the given example is wrong. The segmentation fault is because of missing malloc in creat_queue() function.
I added that malloc and the code runs ok until creat_queue(). Another segmentation fault occurs when insert function is called.
here
struct queue *insert(struct queue *q,int val)
{
struct node *ptr;
ptr = (struct node*)malloc(sizeof(struct node));
ptr->data = val;
if(q->front == NULL)
{
q->front = ptr; //something is wrong here as I keep getting seg fault error in first insertion.
q->rear = ptr;
q->front->next = q->rear->next = NULL;
}
else
{
q->rear->next = ptr;
q->rear = ptr;
q->rear->next = NULL;
}
return q;
}
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2017-03-23 12:35 -0700 |
| Message-ID | <lnh92jair9.fsf@kst-u.example.com> |
| In reply to | #106838 |
acidlategamer@gmail.com writes:
> On Friday, March 24, 2017 at 12:18:14 AM UTC+5:30, Keith Thompson wrote:
>> acidlategamer@gmail.com writes:
>> > On Thursday, March 23, 2017 at 11:34:09 PM UTC+5:30, acidla...@gmail.com wrote:
>> >> On Thursday, March 23, 2017 at 11:22:28 PM UTC+5:30, Joe Pfeiffer wrote:
>> >> > acidlategamer@gmail.com writes:
>> >> > >
>> >> > > I see example codes where q is never initialised to NULL and a
>> >> > > function is there that says 'createq'. All it do in the function is
>> >> > > just make rear and front to point to NULL. At that moment nothing is
>> >> > > allocated to anyone.
>> >> >
>> >> > Either you're misunderstanding the examples, or they are wrong. Do you
>> >> > have a URL?
>> >>
>> >> I am reading a book. I have formatted and removed extra code for better readability.
>> >>
>> >> http://codepad.org/4IiDVzpT
>> >>
>> >> Thanks for your replies.
>> >
>> > Book name is data structures using C - Reema Thareja
>>
>> Either the "extra code" was necessary for correctness, or the code in
>> the book is incorrect.
>>
>> At file scope, you have:
>>
>> struct queue *q;//Here q is not initialized
>>
>> q is not *explicitly* initialized. It's implicitly initialized to NULL.
>> Any file-scope and/or static object without an initializer is implicitly
>> initialized to zero; for a pointer object, that's a null pointer.
>>
>> int main()
>> {
>> int val, option;
>> create_queue(q);//just called create queue. At this moment nothing such as struct node is created
>>
>> At this point, q still has its initial null value, so the call is
>> equivalent to create_queue(NULL). Since function arguments are always
>> passed by value, this cannot change the value of q.
>>
>> void create_queue(struct queue *q)
>> {
>> q -> rear = NULL;//how this happened without any error??
>> q -> front = NULL;
>> }
>>
>> This dereferences a null pointer, causing undefined behavior.
>> You were lucky enough to get a segmentation fault, a clear indication
>> that there's a problem.
>
> I can understand now, that the given example is wrong. The
> segmentation fault is because of missing malloc in creat_queue()
> function.
No, that's not the only problem. For that to work, create_queue() would
have to return a `struct queue *` value. (Or it could take a `struct
queue**` argument, but returning the pointer is probably cleaner and
easier to understand.)
Something like this:
struct queue *new_queue(void) {
struct queue *q = malloc(sizeof *q);
if (q != NULL) {
q->rear = NULL;
q->front = NULL;
}
return q;
}
And of course you'll have to assign the returned value to your pointer
object in main or wherever you call it).
Note that I've changed the name of the function to reflect what it
returns rather than what it does.
[...]
--
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]
| From | acidlategamer@gmail.com |
|---|---|
| Date | 2017-03-23 12:48 -0700 |
| Message-ID | <a6aec47c-e128-4d7b-94c6-b8bb536035ce@googlegroups.com> |
| In reply to | #106844 |
On Friday, March 24, 2017 at 1:05:45 AM UTC+5:30, Keith Thompson wrote:
> acidlategamer@gmail.com writes:
> > On Friday, March 24, 2017 at 12:18:14 AM UTC+5:30, Keith Thompson wrote:
> >> acidlategamer@gmail.com writes:
> >> > On Thursday, March 23, 2017 at 11:34:09 PM UTC+5:30, acidla...@gmail.com wrote:
> >> >> On Thursday, March 23, 2017 at 11:22:28 PM UTC+5:30, Joe Pfeiffer wrote:
> >> >> > acidlategamer@gmail.com writes:
> >> >> > >
> >> >> > > I see example codes where q is never initialised to NULL and a
> >> >> > > function is there that says 'createq'. All it do in the function is
> >> >> > > just make rear and front to point to NULL. At that moment nothing is
> >> >> > > allocated to anyone.
> >> >> >
> >> >> > Either you're misunderstanding the examples, or they are wrong. Do you
> >> >> > have a URL?
> >> >>
> >> >> I am reading a book. I have formatted and removed extra code for better readability.
> >> >>
> >> >> http://codepad.org/4IiDVzpT
> >> >>
> >> >> Thanks for your replies.
> >> >
> >> > Book name is data structures using C - Reema Thareja
> >>
> >> Either the "extra code" was necessary for correctness, or the code in
> >> the book is incorrect.
> >>
> >> At file scope, you have:
> >>
> >> struct queue *q;//Here q is not initialized
> >>
> >> q is not *explicitly* initialized. It's implicitly initialized to NULL.
> >> Any file-scope and/or static object without an initializer is implicitly
> >> initialized to zero; for a pointer object, that's a null pointer.
> >>
> >> int main()
> >> {
> >> int val, option;
> >> create_queue(q);//just called create queue. At this moment nothing such as struct node is created
> >>
> >> At this point, q still has its initial null value, so the call is
> >> equivalent to create_queue(NULL). Since function arguments are always
> >> passed by value, this cannot change the value of q.
> >>
> >> void create_queue(struct queue *q)
> >> {
> >> q -> rear = NULL;//how this happened without any error??
> >> q -> front = NULL;
> >> }
> >>
> >> This dereferences a null pointer, causing undefined behavior.
> >> You were lucky enough to get a segmentation fault, a clear indication
> >> that there's a problem.
> >
> > I can understand now, that the given example is wrong. The
> > segmentation fault is because of missing malloc in creat_queue()
> > function.
>
> No, that's not the only problem. For that to work, create_queue() would
> have to return a `struct queue *` value. (Or it could take a `struct
> queue**` argument, but returning the pointer is probably cleaner and
> easier to understand.)
>
> Something like this:
>
> struct queue *new_queue(void) {
> struct queue *q = malloc(sizeof *q);
> if (q != NULL) {
> q->rear = NULL;
> q->front = NULL;
> }
> return q;
> }
>
> And of course you'll have to assign the returned value to your pointer
> object in main or wherever you call it).
>
> Note that I've changed the name of the function to reflect what it
> returns rather than what it does.
>
> [...]
>
> --
> 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"
I just came to senses.
The malloc I did in create_queue() is a local memory allocation. q will be again uninitialized after the function returns, hence I was getting segmentation faults. I did correct way.
http://codepad.org/sqUT3bx4
Thanks for the super help.
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2017-03-23 13:24 -0700 |
| Message-ID | <lnd1d7aghy.fsf@kst-u.example.com> |
| In reply to | #106845 |
acidlategamer@gmail.com writes:
[...]
> I just came to senses.
> The malloc I did in create_queue() is a local memory allocation. q
> will be again uninitialized after the function returns, hence I was
> getting segmentation faults. I did correct way.
Almost. The memory allocated by malloc() isn't local, it's on the
"heap", and its lifetime continues until it's deallocated by free() or
equivalent, or until the program completes.
What's local is your only pointer to it. When that pointer object
vanishes, you've lost your only reference to the allocated memory.
It's a memory leak.
And q isn't "again uninitialized". You actually have two distinct
objects named "q". One is a global (file-scope) variable. The other
is the parameter to the create_queue() function, which is initialized
with a *copy* of the value of the argument, the global "q". (Parameters
are like local variables, except that they're initialized to the value
of the corresponding argument.)
> http://codepad.org/sqUT3bx4
Here's your updated create_queue() function:
struct queue *create_queue(struct queue *q)
{
q = malloc(sizeof(struct queue));
q -> rear = NULL;//how this happened without any error??
q -> front = NULL;
return q;
}
It takes an argument of type "struct queue*", but it doesn't do anything
with that value; it immediately clobbers it with the value returned by
malloc(). This isn't exactly wrong, but it's useless. You can drop the
parameter and change it to a local variable:
struct queue *create_queue(void)
{
struct queue q = malloc(sizeof(struct queue));
q -> rear = NULL;//how this happened without any error??
q -> front = NULL;
return q;
}
Then the call in your main function becomes:
q = create_queue();
Your insert() function always returns the value of its first parameter,
which it never changes. It might as well be a void function, not
returning a value. (Unless it *should* modify the value of q; I haven't
studied the logic closely enough to be sure.)
Consistent indentation would make your code much easier to read.
--
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]
| From | scott@slp53.sl.home (Scott Lurndal) |
|---|---|
| Date | 2017-03-23 20:46 +0000 |
| Message-ID | <0vWAA.71609$sJ.273@fx06.iad> |
| In reply to | #106838 |
acidlategamer@gmail.com writes: >On Friday, March 24, 2017 at 12:18:14 AM UTC+5:30, Keith Thompson wrote: > >ptr = (struct node*)malloc(sizeof(struct node)); > ptr->data = val; And if the malloc fails?
[toc] | [prev] | [next] | [standalone]
| From | Barry Schwarz <schwarzb@dqel.com> |
|---|---|
| Date | 2017-03-23 19:02 -0700 |
| Message-ID | <ofv8dc1d8l7tuigmeppm3l66vn19l8hhvn@4ax.com> |
| In reply to | #106814 |
On Thu, 23 Mar 2017 09:56:59 -0700 (PDT), acidlategamer@gmail.com wrote: Your subject is self contradictory. You should never attempt to execute a program that does not compile cleanly. It should also link cleanly. -- Remove del for email
[toc] | [prev] | [standalone]
Page 11 of 11 — ← Prev page 1 … 9 10 [11]
Back to top | Article view | comp.lang.c
csiph-web