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 | 20 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 1 of 11 [1] 2 3 … 11 Next page →
| From | acidlategamer@gmail.com |
|---|---|
| Date | 2017-03-23 09:56 -0700 |
| Subject | My C program does not compile or gives segmentation fault |
| Message-ID | <89549322-236e-4a59-9bb5-dc881593a846@googlegroups.com> |
Hi all I am trying to make a sample queue program. I just started with this concept and I am seeing a problem
#include <stdio.h>
#include <stdlib.h>
struct node {
int data;
struct node *next;
};
struct queue{
struct node *front;
struct node *rear;
};
struct queue *q=NULL;//pointer is initialised
q->front = NULL;//pointer members are initialised
q->rear = NULL;//initialised
int main(void)
{
struct node *ptr = NULL;
/*q->front = NULL;
q->rear = NULL;*/
ptr = (struct node *)malloc(sizeof(struct node));
if(ptr == NULL)
{
printf("error allocationg memory\n");
return 1;
}
ptr->next = NULL;
ptr->data = 10;
if(q->front == NULL)
{
q->front = ptr;
q->rear = ptr;
//rest of the logic
}
free(ptr);
return 0;
}
I am getting two problems,
1)If I create
q->front = NULL;
q->rear = NULL;
as global I get this warning
error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘->’ token
q->front = NULL;
^
queue.c:15:2: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘->’ token
q->rear = NULL;
2) If I create same variables inside main, I can compile, but at runtime I am getting segmentation fault.
Why is this happening?
my setup is **gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)**
maybe this is a stupid question.
[toc] | [next] | [standalone]
| From | GOTHIER Nathan <nathan.gothier@gmail.com> |
|---|---|
| Date | 2017-03-23 18:04 +0100 |
| Message-ID | <20170323180402.536716c31998c9345072b8d7@gmail.com> |
| In reply to | #106814 |
On Thu, 23 Mar 2017 09:56:59 -0700 (PDT)
acidlategamer@gmail.com wrote:
> Hi all I am trying to make a sample queue program. I just started with this concept and I am seeing a problem
>
> #include <stdio.h>
> #include <stdlib.h>
> struct node {
> int data;
> struct node *next;
> };
>
> struct queue{
> struct node *front;
> struct node *rear;
> };
>
> struct queue *q=NULL;//pointer is initialised
Here you declare and initialize a pointer (i.e. a memory address)...
> q->front = NULL;//pointer members are initialised
> q->rear = NULL;//initialised
But you can't initialize objects that aren't allocated since your pointer
points to the null memory address where by convention there is no object.
[toc] | [prev] | [next] | [standalone]
| From | Richard Heathfield <rjh@cpax.org.uk> |
|---|---|
| Date | 2017-03-23 17:07 +0000 |
| Message-ID | <ob0v7h$b48$1@dont-email.me> |
| In reply to | #106814 |
On 23/03/17 16:56, acidlategamer@gmail.com wrote:
> Hi all I am trying to make a sample queue program. I just started with this concept and I am seeing a problem
>
> #include <stdio.h>
> #include <stdlib.h>
> struct node {
> int data;
> struct node *next;
> };
>
> struct queue{
> struct node *front;
> struct node *rear;
> };
>
> struct queue *q=NULL;//pointer is initialised
Yes, this is an initialisation of a file scope object, so it's legal.
> q->front = NULL;//pointer members are initialised
No, this is not an initialisation. This is an assignment statement.
Since it appears outside a function body, a diagnostic message is
required. Fix: put it in main(). But that won't solve all your problems,
because q is NULL, so what you are trying to do here is set NULL->front
= NULL, which is never going to work.
> q->rear = NULL;//initialised
Same problems.
> ptr = (struct node *)malloc(sizeof(struct node));
Much cleaner:
ptr = malloc(sizeof *ptr);
>
> I am getting two problems,
>
> 1)If I create
>
> q->front = NULL;
> q->rear = NULL;
>
> as global I get this warning
>
> error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘->’ token
> q->front = NULL;
It's complaining here about your first problem - an assignment statement
outside a function.
> 2) If I create same variables inside main, I can compile, but at runtime I am getting segmentation fault.
That's your second problem: assigning a value to NULL->front.
Fix: wait until q points somewhere valid before trying to set its front
and rear pointers. Until q does point somewhere valid, q->front and
q->rear are meaningless.
--
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within
[toc] | [prev] | [next] | [standalone]
| From | acidlategamer@gmail.com |
|---|---|
| Date | 2017-03-23 10:36 -0700 |
| Message-ID | <7e5f00ae-7843-42e8-9335-c46e1959244c@googlegroups.com> |
| In reply to | #106816 |
On Thursday, March 23, 2017 at 10:37:55 PM UTC+5:30, Richard Heathfield wrote:
> On 23/03/17 16:56, acidlategamer@gmail.com wrote:
> > Hi all I am trying to make a sample queue program. I just started with this concept and I am seeing a problem
> >
> > #include <stdio.h>
> > #include <stdlib.h>
> > struct node {
> > int data;
> > struct node *next;
> > };
> >
> > struct queue{
> > struct node *front;
> > struct node *rear;
> > };
> >
> > struct queue *q=NULL;//pointer is initialised
>
> Yes, this is an initialisation of a file scope object, so it's legal.
>
> > q->front = NULL;//pointer members are initialised
>
> No, this is not an initialisation. This is an assignment statement.
> Since it appears outside a function body, a diagnostic message is
> required. Fix: put it in main(). But that won't solve all your problems,
> because q is NULL, so what you are trying to do here is set NULL->front
> = NULL, which is never going to work.
>
> > q->rear = NULL;//initialised
>
> Same problems.
>
> > ptr = (struct node *)malloc(sizeof(struct node));
>
> Much cleaner:
>
> ptr = malloc(sizeof *ptr);
>
> >
> > I am getting two problems,
> >
> > 1)If I create
> >
> > q->front = NULL;
> > q->rear = NULL;
> >
> > as global I get this warning
> >
> > error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘->’ token
> > q->front = NULL;
>
> It's complaining here about your first problem - an assignment statement
> outside a function.
>
> > 2) If I create same variables inside main, I can compile, but at runtime I am getting segmentation fault.
>
> That's your second problem: assigning a value to NULL->front.
>
> Fix: wait until q points somewhere valid before trying to set its front
> and rear pointers. Until q does point somewhere valid, q->front and
> q->rear are meaningless.
>
> --
> Richard Heathfield
> Email: rjh at cpax dot org dot uk
> "Usenet is a strange place" - dmr 29 July 1999
> Sig line 4 vacant - apply within
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.
[toc] | [prev] | [next] | [standalone]
| From | acidlategamer@gmail.com |
|---|---|
| Date | 2017-03-23 10:42 -0700 |
| Message-ID | <b90bb75d-c16a-4544-964b-d876d71fa9eb@googlegroups.com> |
| In reply to | #106820 |
On Thursday, March 23, 2017 at 11:06:44 PM UTC+5:30, acidla...@gmail.com wrote:
> On Thursday, March 23, 2017 at 10:37:55 PM UTC+5:30, Richard Heathfield wrote:
> > On 23/03/17 16:56, acidlategamer@gmail.com wrote:
> > > Hi all I am trying to make a sample queue program. I just started with this concept and I am seeing a problem
> > >
> > > #include <stdio.h>
> > > #include <stdlib.h>
> > > struct node {
> > > int data;
> > > struct node *next;
> > > };
> > >
> > > struct queue{
> > > struct node *front;
> > > struct node *rear;
> > > };
> > >
> > > struct queue *q=NULL;//pointer is initialised
> >
> > Yes, this is an initialisation of a file scope object, so it's legal.
> >
> > > q->front = NULL;//pointer members are initialised
> >
> > No, this is not an initialisation. This is an assignment statement.
> > Since it appears outside a function body, a diagnostic message is
> > required. Fix: put it in main(). But that won't solve all your problems,
> > because q is NULL, so what you are trying to do here is set NULL->front
> > = NULL, which is never going to work.
> >
> > > q->rear = NULL;//initialised
> >
> > Same problems.
> >
> > > ptr = (struct node *)malloc(sizeof(struct node));
> >
> > Much cleaner:
> >
> > ptr = malloc(sizeof *ptr);
> >
> > >
> > > I am getting two problems,
> > >
> > > 1)If I create
> > >
> > > q->front = NULL;
> > > q->rear = NULL;
> > >
> > > as global I get this warning
> > >
> > > error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘->’ token
> > > q->front = NULL;
> >
> > It's complaining here about your first problem - an assignment statement
> > outside a function.
> >
> > > 2) If I create same variables inside main, I can compile, but at runtime I am getting segmentation fault.
> >
> > That's your second problem: assigning a value to NULL->front.
> >
> > Fix: wait until q points somewhere valid before trying to set its front
> > and rear pointers. Until q does point somewhere valid, q->front and
> > q->rear are meaningless.
> >
> > --
> > Richard Heathfield
> > Email: rjh at cpax dot org dot uk
> > "Usenet is a strange place" - dmr 29 July 1999
> > Sig line 4 vacant - apply within
>
> 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. Like this
int main()
{
create_queue(q);//
//some code
}
create_queue(struct queue* q)
{
q -> rear = NULL;
q -> front = NULL;
}
So what does that mean?
[toc] | [prev] | [next] | [standalone]
| From | GOTHIER Nathan <nathan.gothier@gmail.com> |
|---|---|
| Date | 2017-03-23 18:52 +0100 |
| Message-ID | <20170323185230.97aa522ba7915c2397aaf257@gmail.com> |
| In reply to | #106823 |
On Thu, 23 Mar 2017 10:42:14 -0700 (PDT)
acidlategamer@gmail.com wrote:
> int main()
> {
> create_queue(q);//
> //some code
> }
> create_queue(struct queue* q)
> {
> q -> rear = NULL;
> q -> front = NULL;
> }
>
> So what does that mean?
It means you should rather learn C before asking trivial questions. ;-)
[toc] | [prev] | [next] | [standalone]
| From | Joe Pfeiffer <pfeiffer@cs.nmsu.edu> |
|---|---|
| Date | 2017-03-23 12:54 -0600 |
| Message-ID | <1bo9wraknp.fsf@pfeifferfamily.net> |
| In reply to | #106826 |
GOTHIER Nathan <nathan.gothier@gmail.com> writes:
> On Thu, 23 Mar 2017 10:42:14 -0700 (PDT)
> acidlategamer@gmail.com wrote:
>
>> int main()
>> {
>> create_queue(q);//
>> //some code
>> }
>> create_queue(struct queue* q)
>> {
>> q -> rear = NULL;
>> q -> front = NULL;
>> }
>>
>> So what does that mean?
>
> It means you should rather learn C before asking trivial questions. ;-)
If you can't be helpful, please be quiet.
[toc] | [prev] | [next] | [standalone]
| From | GOTHIER Nathan <nathan.gothier@gmail.com> |
|---|---|
| Date | 2017-03-24 00:02 +0100 |
| Message-ID | <20170324000233.226a71fab90c2d42568be490@gmail.com> |
| In reply to | #106836 |
On Thu, 23 Mar 2017 12:54:34 -0600 Joe Pfeiffer <pfeiffer@cs.nmsu.edu> wrote: > If you can't be helpful, please be quiet. I'm afraid you're confusing me with one of your students... so just mind your own business the class is over!
[toc] | [prev] | [next] | [standalone]
| From | Joe Pfeiffer <pfeiffer@cs.nmsu.edu> |
|---|---|
| Date | 2017-03-23 17:16 -0600 |
| Message-ID | <1bbmsra8im.fsf@pfeifferfamily.net> |
| In reply to | #106858 |
GOTHIER Nathan <nathan.gothier@gmail.com> writes: > On Thu, 23 Mar 2017 12:54:34 -0600 > Joe Pfeiffer <pfeiffer@cs.nmsu.edu> wrote: > >> If you can't be helpful, please be quiet. > > I'm afraid you're confusing me with one of your students... so just mind your > own business the class is over! No, I was confusing you with someone who might possibly stop being an asshole if it were pointed out to him. I'll not make that mistake again.
[toc] | [prev] | [next] | [standalone]
| From | GOTHIER Nathan <nathan.gothier@gmail.com> |
|---|---|
| Date | 2017-03-24 00:32 +0100 |
| Message-ID | <20170324003244.97cf445b22026a60fd0983af@gmail.com> |
| In reply to | #106859 |
On Thu, 23 Mar 2017 17:16:49 -0600 Joe Pfeiffer <pfeiffer@cs.nmsu.edu> wrote: > No, I was confusing you with someone who might possibly stop being an > asshole if it were pointed out to him. I'll not make that mistake > again. After so many years in the academic field you only learned insults... you're pathetic old man! It's sad nobody will regret you after you passed away.
[toc] | [prev] | [next] | [standalone]
| From | Joe Pfeiffer <pfeiffer@cs.nmsu.edu> |
|---|---|
| Date | 2017-03-23 11:57 -0600 |
| Message-ID | <1b1stnc1vj.fsf@pfeifferfamily.net> |
| In reply to | #106823 |
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. Like this
>
> int main()
> {
> create_queue(q);//
> //some code
> }
> create_queue(struct queue* q)
> {
> q -> rear = NULL;
> q -> front = NULL;
> }
This isn't the whole program, of course. What does the complete program
look like?
[toc] | [prev] | [next] | [standalone]
| From | acidlategamer@gmail.com |
|---|---|
| Date | 2017-03-23 11:23 -0700 |
| Message-ID | <f1a49516-73ba-4408-90f6-177f77d99050@googlegroups.com> |
| In reply to | #106827 |
On Thursday, March 23, 2017 at 11:27:27 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. Like this
> >
> > int main()
> > {
> > create_queue(q);//
> > //some code
> > }
> > create_queue(struct queue* q)
> > {
> > q -> rear = NULL;
> > q -> front = NULL;
> > }
>
> This isn't the whole program, of course. What does the complete program
> look like?
Also I came across this code on another website
http://quiz.geeksforgeeks.org/queue-set-2-linked-list-implementation/
[toc] | [prev] | [next] | [standalone]
| From | Joe Pfeiffer <pfeiffer@cs.nmsu.edu> |
|---|---|
| Date | 2017-03-23 12:53 -0600 |
| Message-ID | <1bshm3akop.fsf@pfeifferfamily.net> |
| In reply to | #106831 |
acidlategamer@gmail.com writes:
> On Thursday, March 23, 2017 at 11:27:27 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. Like this
>> >
>> > int main()
>> > {
>> > create_queue(q);//
>> > //some code
>> > }
>> > create_queue(struct queue* q)
>> > {
>> > q -> rear = NULL;
>> > q -> front = NULL;
>> > }
>>
>> This isn't the whole program, of course. What does the complete program
>> look like?
>
> 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();
so it calls createQueue() from within main().
Within createQueue(), we have:
struct Queue *createQueue()
{
struct Queue *q = (struct Queue*)malloc(sizeof(struct Queue));
q->front = q->rear = NULL;
return q;
}
The call to malloc() reserves space for q, and points it at that space.
The function then returns the allocated space to the main program.
(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 it is simpler, the cast is unnecessary, and changing
the type of q at some point in the future automatically still works
without remembering to change the argument to sizeof. Others regard the
longer version as being a bit of self-documentation.
Also, it's a good idea to check the return value from malloc(); if the
call fails then the the value returned by malloc() will be NULL)
[toc] | [prev] | [next] | [standalone]
| From | Richard Heathfield <rjh@cpax.org.uk> |
|---|---|
| Date | 2017-03-23 19:00 +0000 |
| Message-ID | <ob15rr$4kg$1@dont-email.me> |
| In reply to | #106835 |
On 23/03/17 18:53, Joe Pfeiffer wrote: <snip> > > 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 it is simpler, the cast is unnecessary, and changing > the type of q at some point in the future automatically still works > without remembering to change the argument to sizeof. It's also much easier to read, and easier to see that it's correct. > Others regard the > longer version as being a bit of self-documentation. And, like all documentation, it runs the danger of becoming outdated. > Also, it's a good idea to check the return value from malloc(); if the > call fails then the the value returned by malloc() will be NULL) Right. -- Richard Heathfield Email: rjh at cpax dot org dot uk "Usenet is a strange place" - dmr 29 July 1999 Sig line 4 vacant - apply within
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2017-03-23 15:59 -0400 |
| Message-ID | <ob199u$i07$1@jstuckle.eternal-september.org> |
| In reply to | #106839 |
On 3/23/2017 3:00 PM, Richard Heathfield wrote: > On 23/03/17 18:53, Joe Pfeiffer wrote: > <snip> >> >> 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 it is simpler, the cast is unnecessary, and changing >> the type of q at some point in the future automatically still works >> without remembering to change the argument to sizeof. > > It's also much easier to read, and easier to see that it's correct. > >> Others regard the >> longer version as being a bit of self-documentation. > > And, like all documentation, it runs the danger of becoming outdated. > It is also recommended by the SEI CERT C Coding Standard at https://www.securecoding.cert.org/confluence/display/c/SEI+CERT+C+Coding+Standard See recommendation MEM02-C (Memory Management): https://www.securecoding.cert.org/confluence/display/c/MEM02-C.+Immediately+cast+the+result+of+a+memory+allocation+function+call+into+a+pointer+to+the+allocated+type -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | Richard Heathfield <rjh@cpax.org.uk> |
|---|---|
| Date | 2017-03-23 20:40 +0000 |
| Message-ID | <ob1blh$r6o$1@dont-email.me> |
| In reply to | #106847 |
On 23/03/17 19:59, Jerry Stuckle wrote: > On 3/23/2017 3:00 PM, Richard Heathfield wrote: >> On 23/03/17 18:53, Joe Pfeiffer wrote: >> <snip> >>> >>> 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 it is simpler, the cast is unnecessary, and changing >>> the type of q at some point in the future automatically still works >>> without remembering to change the argument to sizeof. >> >> It's also much easier to read, and easier to see that it's correct. >> >>> Others regard the >>> longer version as being a bit of self-documentation. >> >> And, like all documentation, it runs the danger of becoming outdated. >> > > It is also recommended by the SEI CERT C Coding Standard at > https://www.securecoding.cert.org/confluence/display/c/SEI+CERT+C+Coding+Standard Yes, I know. But it's still a bad idea. -- Richard Heathfield Email: rjh at cpax dot org dot uk "Usenet is a strange place" - dmr 29 July 1999 Sig line 4 vacant - apply within
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2017-03-23 22:06 +0100 |
| Message-ID | <ob1d83$1gv$1@dont-email.me> |
| In reply to | #106850 |
On 23/03/17 21:40, Richard Heathfield wrote: > On 23/03/17 19:59, Jerry Stuckle wrote: >> On 3/23/2017 3:00 PM, Richard Heathfield wrote: >>> On 23/03/17 18:53, Joe Pfeiffer wrote: >>> <snip> >>>> >>>> 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 it is simpler, the cast is unnecessary, and >>>> changing >>>> the type of q at some point in the future automatically still works >>>> without remembering to change the argument to sizeof. >>> >>> It's also much easier to read, and easier to see that it's correct. >>> >>>> Others regard the >>>> longer version as being a bit of self-documentation. >>> >>> And, like all documentation, it runs the danger of becoming outdated. >>> >> >> It is also recommended by the SEI CERT C Coding Standard at >> https://www.securecoding.cert.org/confluence/display/c/SEI+CERT+C+Coding+Standard >> > > Yes, I know. But it's still a bad idea. > A key point in the example on the cert site is that there is a distance between the pointer definition, and the assignment to it: widget *p; /* ... */ p = malloc(sizeof(gadget)); In code like that, the risk of getting the malloc wrong is much higher, and thus the benefits of putting in the cast are much higher, compared to: widget *p = malloc(sizeof(gadget)); or widget *p = malloc(sizeof *p); IMHO, a key point is to define the pointer variable only when you need it - make the malloc an initialisation, not an assignment. That gives you "self-documenting code", with the type written only once, and shows the reader exactly what is happening, unlike *p = malloc(sizeof *p);
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2017-03-23 20:43 -0400 |
| Message-ID | <ob1pt6$avm$2@jstuckle.eternal-september.org> |
| In reply to | #106850 |
On 3/23/2017 4:40 PM, Richard Heathfield wrote: > On 23/03/17 19:59, Jerry Stuckle wrote: >> On 3/23/2017 3:00 PM, Richard Heathfield wrote: >>> On 23/03/17 18:53, Joe Pfeiffer wrote: >>> <snip> >>>> >>>> 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 it is simpler, the cast is unnecessary, and >>>> changing >>>> the type of q at some point in the future automatically still works >>>> without remembering to change the argument to sizeof. >>> >>> It's also much easier to read, and easier to see that it's correct. >>> >>>> Others regard the >>>> longer version as being a bit of self-documentation. >>> >>> And, like all documentation, it runs the danger of becoming outdated. >>> >> >> It is also recommended by the SEI CERT C Coding Standard at >> https://www.securecoding.cert.org/confluence/display/c/SEI+CERT+C+Coding+Standard >> > > Yes, I know. But it's still a bad idea. > So you know more than CERT. ROFLMAO! -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2017-03-24 14:09 +1300 |
| Message-ID | <ejj9tiFmdulU2@mid.individual.net> |
| In reply to | #106862 |
On 03/24/17 01:43 PM, Jerry Stuckle wrote: > On 3/23/2017 4:40 PM, Richard Heathfield wrote: >> On 23/03/17 19:59, Jerry Stuckle wrote: >>> On 3/23/2017 3:00 PM, Richard Heathfield wrote: >>>> On 23/03/17 18:53, Joe Pfeiffer wrote: >>>> <snip> >>>>> >>>>> 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 it is simpler, the cast is unnecessary, and >>>>> changing >>>>> the type of q at some point in the future automatically still works >>>>> without remembering to change the argument to sizeof. >>>> >>>> It's also much easier to read, and easier to see that it's correct. >>>> >>>>> Others regard the >>>>> longer version as being a bit of self-documentation. >>>> >>>> And, like all documentation, it runs the danger of becoming outdated. >>>> >>> >>> It is also recommended by the SEI CERT C Coding Standard at >>> https://www.securecoding.cert.org/confluence/display/c/SEI+CERT+C+Coding+Standard >>> >> >> Yes, I know. But it's still a bad idea. >> > > So you know more than CERT. ROFLMAO! The authour agrees with the consensus here in a later comment: "Much earlier, John Bode suggested the following compliant solution: widget *p; ... p = malloc(sizeof *p); as well as the use of Abstract Data Types (ADT). The ADT discussion is probably orthogonal to this guideline, but the approach of taking the sizeof *p seems to be a reasonable compliant solution that would seem to be noncompliant given the title of this rule." -- Ian
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2017-03-23 21:28 -0400 |
| Message-ID | <ob1sio$h8v$1@jstuckle.eternal-september.org> |
| In reply to | #106864 |
On 3/23/2017 9:09 PM, Ian Collins wrote: > On 03/24/17 01:43 PM, Jerry Stuckle wrote: >> On 3/23/2017 4:40 PM, Richard Heathfield wrote: >>> On 23/03/17 19:59, Jerry Stuckle wrote: >>>> On 3/23/2017 3:00 PM, Richard Heathfield wrote: >>>>> On 23/03/17 18:53, Joe Pfeiffer wrote: >>>>> <snip> >>>>>> >>>>>> 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 it is simpler, the cast is unnecessary, and >>>>>> changing >>>>>> the type of q at some point in the future automatically still works >>>>>> without remembering to change the argument to sizeof. >>>>> >>>>> It's also much easier to read, and easier to see that it's correct. >>>>> >>>>>> Others regard the >>>>>> longer version as being a bit of self-documentation. >>>>> >>>>> And, like all documentation, it runs the danger of becoming outdated. >>>>> >>>> >>>> It is also recommended by the SEI CERT C Coding Standard at >>>> https://www.securecoding.cert.org/confluence/display/c/SEI+CERT+C+Coding+Standard >>>> >>>> >>> >>> Yes, I know. But it's still a bad idea. >>> >> >> So you know more than CERT. ROFLMAO! > > The authour agrees with the consensus here in a later comment: > > "Much earlier, John Bode suggested the following compliant solution: > widget *p; > ... > p = malloc(sizeof *p); > > as well as the use of Abstract Data Types (ADT). The ADT discussion is > probably orthogonal to this guideline, but the approach of taking the > sizeof *p seems to be a reasonable compliant solution that would seem to > be noncompliant given the title of this rule." > Which is *noncomplient*. Reasonable or not. -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
Page 1 of 11 [1] 2 3 … 11 Next page →
Back to top | Article view | comp.lang.c
csiph-web