Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #101847 > unrolled thread
| Started by | "Fernando D. Bozzo" <fdbozzo@gmail.com> |
|---|---|
| First post | 2017-01-15 08:45 -0800 |
| Last post | 2017-01-30 05:21 -0800 |
| Articles | 11 on this page of 151 — 22 participants |
Back to article view | Back to comp.lang.c
Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 08:45 -0800
Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-15 16:53 +0000
Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-15 09:34 -0800
Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-17 21:09 +0000
Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-17 13:45 -0800
Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-17 14:09 -0800
Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-17 22:41 +0000
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 15:06 -0800
Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-17 16:49 -0800
Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-17 16:56 -0800
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 20:37 -0800
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-18 09:38 +0100
Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-31 08:49 -0800
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-31 10:39 -0800
Re: Dinamic array without malloc - Can be done? luser droog <luser.droog@gmail.com> - 2017-01-31 10:55 -0800
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-31 11:40 -0800
Re: Dinamic array without malloc - Can be done? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-01-31 10:57 -0800
Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-03 23:06 -0800
Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 10:42 -0800
Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-15 20:15 +0000
Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-15 12:43 -0800
Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 15:08 -0800
Re: Dinamic array without malloc - Can be done? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-01-15 12:25 -0500
Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 10:46 -0800
Re: Dinamic array without malloc - Can be done? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-15 20:13 +0000
Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 15:06 -0800
Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-15 12:46 -0800
Re: Dinamic array without malloc - Can be done? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-01-15 16:10 -0500
Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 20:37 -0800
Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-15 21:02 -0800
Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-30 04:23 -0800
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 09:05 +0100
Re: Dinamic array without malloc - Can be done? Ian Collins <ian-news@hotmail.com> - 2017-01-16 21:16 +1300
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 09:48 +0100
Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-15 09:29 -0800
Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-15 09:37 -0800
Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-15 09:56 -0800
Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-15 10:34 -0800
Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 10:48 -0800
Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-15 11:10 -0800
Re: Dinamic array without malloc - Can be done? Jean-Marc Bourguet <jm@bourguet.org> - 2017-01-15 20:22 +0100
Re: Dinamic array without malloc - Can be done? Chad <cdalten@gmail.com> - 2017-01-15 11:50 -0800
Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 15:12 -0800
Re: Dinamic array without malloc - Can be done? Richard Heathfield <rjh@cpax.org.uk> - 2017-01-15 17:50 +0000
Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 10:38 -0800
Re: Dinamic array without malloc - Can be done? Richard Heathfield <rjh@cpax.org.uk> - 2017-01-15 19:34 +0000
Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-15 12:51 -0800
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-15 13:10 -0800
Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-15 16:23 -0800
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-15 18:08 -0800
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 09:56 +0100
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-16 08:35 -0800
Re: Dinamic array without malloc - Can be done? "Chris M. Thomasson" <invalid@invalid.invalid> - 2017-01-16 11:07 -0800
Re: Dinamic array without malloc - Can be done? "Chris M. Thomasson" <invalid@invalid.invalid> - 2017-01-16 11:17 -0800
Re: Dinamic array without malloc - Can be done? Robert Wessel <robertwessel2@yahoo.com> - 2017-01-16 15:21 -0600
Re: Dinamic array without malloc - Can be done? "Chris M. Thomasson" <invalid@invalid.invalid> - 2017-01-31 22:22 -0800
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 00:22 +0100
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-16 16:23 -0800
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 02:04 +0100
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-16 17:27 -0800
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 09:16 +0100
Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 20:32 -0800
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 10:02 +0100
Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-16 09:22 -0800
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 00:25 +0100
Re: Dinamic array without malloc - Can be done? Barry Schwarz <schwarzb@dqel.com> - 2017-01-15 11:53 -0800
Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-15 12:22 -0800
Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 15:32 -0800
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-15 16:01 -0800
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 10:19 +0100
Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-16 11:28 +0000
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 14:29 +0100
Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-16 15:41 +0000
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 17:27 +0100
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-16 07:56 -0800
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 17:31 +0100
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-16 08:48 -0800
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 00:29 +0100
Re: Dinamic array without malloc - Can be done? "Chris M. Thomasson" <invalid@invalid.invalid> - 2017-01-16 11:25 -0800
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-16 12:28 -0800
Re: Dinamic array without malloc - Can be done? "Chris M. Thomasson" <invalid@invalid.invalid> - 2017-01-16 12:38 -0800
Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-15 16:57 -0800
Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-16 00:37 -0800
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 10:23 +0100
Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-16 01:35 -0800
Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-16 09:15 -0800
Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-16 01:29 +0000
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-16 10:08 +0100
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-16 08:08 -0800
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 00:35 +0100
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-16 16:31 -0800
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 09:27 +0100
Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-17 12:11 +0000
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 14:23 +0100
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 05:38 -0800
Re: Dinamic array without malloc - Can be done? BartC <bc@freeuk.com> - 2017-01-17 14:17 +0000
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 07:09 -0800
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 05:14 -0800
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 14:40 +0100
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 06:41 -0800
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-17 16:00 +0100
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 07:45 -0800
Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-17 08:18 -0800
Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-17 08:27 -0800
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 09:29 -0800
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 09:23 -0800
Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-17 10:35 -0800
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 12:41 -0800
Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-17 13:45 -0800
Re: Dinamic array without malloc - Can be done? Robert Wessel <robertwessel2@yahoo.com> - 2017-01-17 21:00 -0600
Re: Dinamic array without malloc - Can be done? fir <profesor.fir@gmail.com> - 2017-01-15 11:55 -0800
Re: Dinamic array without malloc - Can be done? Siri Cruise <chine.bleu@yahoo.com> - 2017-01-15 14:59 -0800
Re: Dinamic array without malloc - Can be done? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-15 20:04 +0000
Re: Dinamic array without malloc - Can be done? David Brown <david.brown@hesbynett.no> - 2017-01-15 21:33 +0100
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-15 13:00 -0800
Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 20:27 -0800
Re: Dinamic array without malloc - Can be done? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-01-15 16:34 -0500
Re: Dinamic array without malloc - Can be done? "James R. Kuyper" <jameskuyper@verizon.net> - 2017-01-15 16:43 -0500
Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-15 16:17 -0800
Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 20:22 -0800
Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-15 21:00 -0800
Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-30 05:01 -0800
Re: Dinamic array without malloc - Can be done? Keith Thompson <kst-u@mib.org> - 2017-01-30 11:35 -0800
Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-01 16:18 -0800
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-02-01 16:37 -0800
Re: Dinamic array without malloc - Can be done? Robert Wessel <robertwessel2@yahoo.com> - 2017-02-01 23:21 -0600
Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-02 00:27 -0800
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-02-02 10:58 -0800
Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-03 22:51 -0800
Re: Dinamic array without malloc - Can be done? "Chris M. Thomasson" <invalid@invalid.invalid> - 2017-01-15 15:41 -0800
Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-15 15:44 -0800
Re: Dinamic array without malloc - Can be done? "Chris M. Thomasson" <invalid@invalid.invalid> - 2017-01-15 16:17 -0800
Re: Dinamic array without malloc - Can be done? Alla _ <modelling.data@gmail.com> - 2017-01-16 01:47 -0800
Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-16 01:50 -0800
Re: Dinamic array without malloc - Can be done? Alla _ <modelling.data@gmail.com> - 2017-01-16 02:38 -0800
Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-16 03:15 -0800
Re: Dinamic array without malloc - Can be done? Alla _ <modelling.data@gmail.com> - 2017-01-16 03:40 -0800
Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-16 04:21 -0800
Re: Dinamic array without malloc - Can be done? Alla _ <modelling.data@gmail.com> - 2017-01-16 04:29 -0800
Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-16 04:36 -0800
Re: Dinamic array without malloc - Can be done? Richard Heathfield <rjh@cpax.org.uk> - 2017-01-16 11:36 +0000
Re: Dinamic array without malloc - Can be done? Alla _ <modelling.data@gmail.com> - 2017-01-16 03:44 -0800
Re: Dinamic array without malloc - Can be done? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-16 15:34 +0000
Re: Dinamic array without malloc - Can be done? Richard Heathfield <rjh@cpax.org.uk> - 2017-01-16 16:01 +0000
Re: Dinamic array without malloc - Can be done? John Bode <jfbode1029@gmail.com> - 2017-01-17 10:14 -0800
Re: Dinamic array without malloc - Can be done? James Kuyper <jameskuyper@verizon.net> - 2017-01-17 13:21 -0500
Re: Dinamic array without malloc - Can be done? John Bode <jfbode1029@gmail.com> - 2017-01-17 11:43 -0800
Re: Dinamic array without malloc - Can be done? James Kuyper <jameskuyper@verizon.net> - 2017-01-17 15:07 -0500
Re: Dinamic array without malloc - Can be done? supercat@casperkitty.com - 2017-01-17 12:24 -0800
Re: Dinamic array without malloc - Can be done? "Fernando D. Bozzo" <fdbozzo@gmail.com> - 2017-01-17 10:24 -0800
Re: Dinamic array without malloc - Can be done? Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-30 05:21 -0800
Page 8 of 8 — ← Prev page 1 2 3 4 5 6 7 [8]
| From | Richard Heathfield <rjh@cpax.org.uk> |
|---|---|
| Date | 2017-01-16 11:36 +0000 |
| Message-ID | <o5ib5b$suh$1@dont-email.me> |
| In reply to | #101943 |
On 16/01/17 09:47, Alla _ wrote: > On Sunday, January 15, 2017 at 7:45:57 PM UTC+3, Fernando D. Bozzo wrote: >> From the beginning of my course I'm looking a way to define an array with a number of elements based on some other variable which I don't know, but without using the dynamic memory space (with malloc) > <snip> > Could you, please, share what course are you taking? I have a bad feeling about this... Alla, do you not realise that there seem to be quite a few people here in clc who are impatiently awaiting the time when you stop doing C courses, so that they can get on with teaching you C? -- 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 | Alla _ <modelling.data@gmail.com> |
|---|---|
| Date | 2017-01-16 03:44 -0800 |
| Message-ID | <21e4f4e7-ab0a-4679-a4e8-88865de0b5dc@googlegroups.com> |
| In reply to | #101949 |
On Monday, January 16, 2017 at 2:36:50 PM UTC+3, Richard Heathfield wrote: > On 16/01/17 09:47, Alla _ wrote: > > On Sunday, January 15, 2017 at 7:45:57 PM UTC+3, Fernando D. Bozzo wrote: > >> From the beginning of my course I'm looking a way to define an array with a number of elements based on some other variable which I don't know, but without using the dynamic memory space (with malloc) > > <snip> > > Could you, please, share what course are you taking? > > I have a bad feeling about this... > > Alla, do you not realise that there seem to be quite a few people here > in clc who are impatiently awaiting the time when you stop doing C > courses, so that they can get on with teaching you C? > Richard, I don't do any more courses, truly. It's still that same one, but I am done with course itself; I am writing (very very slowly) the final project, and as you see I have chosen the C one, and do it step by step learning good habits. I am doing my best. I have asked Fernando only because I was somehow sure it's this course, so I was curious. I am truly not seeking for any courses. Please, believe me.
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2017-01-16 15:34 +0000 |
| Message-ID | <87k29vhvdg.fsf@bsb.me.uk> |
| In reply to | #101949 |
Richard Heathfield <rjh@cpax.org.uk> writes: <snip> > Alla, do you not realise that there seem to be quite a few people here > in clc who are impatiently awaiting the time when you stop doing C > courses, so that they can get on with teaching you C? I don't think Alla_ is taking any C courses. -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | Richard Heathfield <rjh@cpax.org.uk> |
|---|---|
| Date | 2017-01-16 16:01 +0000 |
| Message-ID | <o5iqmg$l1i$2@dont-email.me> |
| In reply to | #101967 |
On 16/01/17 15:34, Ben Bacarisse wrote: > Richard Heathfield <rjh@cpax.org.uk> writes: > <snip> >> Alla, do you not realise that there seem to be quite a few people here >> in clc who are impatiently awaiting the time when you stop doing C >> courses, so that they can get on with teaching you C? > > I don't think Alla_ is taking any C courses. That's a blessing. :-) Courses, then, C or otherwise. I mean, of course, the kinds of courses that are driving Alla's C studies faster than is good for her. -- 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 | John Bode <jfbode1029@gmail.com> |
|---|---|
| Date | 2017-01-17 10:14 -0800 |
| Message-ID | <ee18bd0a-b0d2-42f1-b6d4-e82a5c13d94e@googlegroups.com> |
| In reply to | #101847 |
On Sunday, January 15, 2017 at 10:45:57 AM UTC-6, Fernando D. Bozzo wrote:
> From the beginning of my course I'm looking a way to define an array with
> a number of elements based on some other variable which I don't know, but
> without using the dynamic memory space (with malloc)
>
> May be I have a conceptual error here, but just in case I did prefer to
> ask.
>
> I want to do something like this:
>
> len = (some calculated length that can vary in every execution);
> char myArray[len];
>
>
> I've tryied this way, but didn't compile. My aim is not needing to free()
> it later, but that this array get cleared as all other auto variables.
>
>
> Thanks.-
C99 introduced variable-length arrays, which pretty much do what you want:
size_t len = get_length_from_somewhere();
int arr[len];
arr behaves pretty much like any other array variable (including being
deallocated when the function exits), with the following exceptions:
- VLAs may not be declared or defined at file scope (outside the body of
any function), nor may they be declared with the "static" keyword. Such
objects have memory allocated for them when the program is first loaded
(before the program actually starts running). Since the size of the array
isn't known until runtime, you can't allocate space for it before the
program runs.
- VLAs may not be members of struct or union types, again because the
size isn't known until runtime, and the compiler can't know how much space
to set aside for a particular struct or union instance.
Whether space for the VLA is allocated on the stack or heap (or some other
area) isn't specified; however, it's best to assume that VLAs are allocated
like other auto variables, meaning the memory available for them is limited
- if you need something that's more than a few kilobytes wide, use dynamic
memory.
You can mix VLAs with dynamic memory. Suppose you want to allocate a
*contiguous* NxM array, but M isn't known until runtime. You could
do something like the following:
size_t cols = get_cols_from_somewhere();
size_t rows = get_rows_from_somewhere();
int (*arr)[cols] = malloc( sizeof ( int [cols] ) * rows );
if ( arr )
{
// do something with arr[i][j]
...
// finished, deallocate arr
free( arr );
}
Normally I'd write "sizeof *arr" to get the size of the target, but
strictly speaking that invokes undefined behavior for VLAs (even though I
and a few others will argue that the standard is badly worded in that
particular area).
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2017-01-17 13:21 -0500 |
| Message-ID | <o5ln81$bpk$1@dont-email.me> |
| In reply to | #102058 |
On 01/17/2017 01:14 PM, John Bode wrote: ... > Normally I'd write "sizeof *arr" to get the size of the target, but > strictly speaking that invokes undefined behavior for VLAs (even though I > and a few others will argue that the standard is badly worded in that > particular area). Which wording are you referring to? 6.5.3.4p2 says "If the type of the operand is a variable length array type, the operand is evaluated; otherwise, the operand is not evaluated and the result is an integer constant."
[toc] | [prev] | [next] | [standalone]
| From | John Bode <jfbode1029@gmail.com> |
|---|---|
| Date | 2017-01-17 11:43 -0800 |
| Message-ID | <1c06ca0f-52f5-4834-bad5-8d489386971d@googlegroups.com> |
| In reply to | #102059 |
On Tuesday, January 17, 2017 at 12:21:28 PM UTC-6, James Kuyper wrote: > On 01/17/2017 01:14 PM, John Bode wrote: > ... > > Normally I'd write "sizeof *arr" to get the size of the target, but > > strictly speaking that invokes undefined behavior for VLAs (even though I > > and a few others will argue that the standard is badly worded in that > > particular area). > > Which wording are you referring to? > > 6.5.3.4p2 says "If the type of the operand is a variable length array > type, the operand is evaluated; otherwise, the operand is not evaluated > and the result is an integer constant." 6.5.3.2p4: "...If an invalid value has been assigned to the pointer, the behavior of the unary * operator is undefined". An uninitialized auto pointer is invalid, thus evaluating "*arr* in "sizeof *arr" is *technically* undefined. Now, you and I both know that *in this particular circumstance" there's no dereference operation involved (at least, there's no *need* for one); however, the standard doesn't call that out as an exception.
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Date | 2017-01-17 15:07 -0500 |
| Message-ID | <o5ltev$5l2$1@dont-email.me> |
| In reply to | #102066 |
On 01/17/2017 02:43 PM, John Bode wrote: > On Tuesday, January 17, 2017 at 12:21:28 PM UTC-6, James Kuyper wrote: >> On 01/17/2017 01:14 PM, John Bode wrote: >> ... >>> Normally I'd write "sizeof *arr" to get the size of the target, but >>> strictly speaking that invokes undefined behavior for VLAs (even though I >>> and a few others will argue that the standard is badly worded in that >>> particular area). >> >> Which wording are you referring to? >> >> 6.5.3.4p2 says "If the type of the operand is a variable length array >> type, the operand is evaluated; otherwise, the operand is not evaluated >> and the result is an integer constant." > > 6.5.3.2p4: "...If an invalid value has been assigned to the pointer, the > behavior of the unary * operator is undefined". > > An uninitialized auto pointer is invalid, thus evaluating "*arr* in > "sizeof *arr" is *technically* undefined. OK - I found the first declaration of "arr" in your message, and it didn't occur to me to look for a second one. If I had been reading C source code, rather than a message about C, I would have searched backwards from the point of reference, and found the right declaration. Your comment makes sense in terms of the second declaration of arr.
[toc] | [prev] | [next] | [standalone]
| From | supercat@casperkitty.com |
|---|---|
| Date | 2017-01-17 12:24 -0800 |
| Message-ID | <37d3e17a-f168-4b9d-b9ee-9dd30342f4b6@googlegroups.com> |
| In reply to | #102059 |
On Tuesday, January 17, 2017 at 12:21:28 PM UTC-6, James Kuyper wrote: > On 01/17/2017 01:14 PM, John Bode wrote: > ... > > Normally I'd write "sizeof *arr" to get the size of the target, but > > strictly speaking that invokes undefined behavior for VLAs (even though I > > and a few others will argue that the standard is badly worded in that > > particular area). > > Which wording are you referring to? > > 6.5.3.4p2 says "If the type of the operand is a variable length array > type, the operand is evaluated; otherwise, the operand is not evaluated > and the result is an integer constant." After "int (*arr)[cols] = malloc( sizeof ( int [cols] ) * rows );" the expression "*arr" would be an array whose value is indeterminate. The Standard says that evaluating things which have Indeterminate Value will yield Undefined Behavior except in certain cases, and I don't think it defines the "evaluation" of an array as one of those cases.
[toc] | [prev] | [next] | [standalone]
| From | "Fernando D. Bozzo" <fdbozzo@gmail.com> |
|---|---|
| Date | 2017-01-17 10:24 -0800 |
| Message-ID | <e8baa7c9-b47b-4cda-92b0-48eefb4571d2@googlegroups.com> |
| In reply to | #102058 |
El martes, 17 de enero de 2017, 19:14:59 (UTC+1), John Bode escribió:
<snip>
>
> C99 introduced variable-length arrays, which pretty much do what you want:
>
> size_t len = get_length_from_somewhere();
> int arr[len];
>
> arr behaves pretty much like any other array variable (including being
> deallocated when the function exits), with the following exceptions:
>
> - VLAs may not be declared or defined at file scope (outside the body of
> any function), nor may they be declared with the "static" keyword. Such
> objects have memory allocated for them when the program is first loaded
> (before the program actually starts running). Since the size of the array
> isn't known until runtime, you can't allocate space for it before the
> program runs.
>
> - VLAs may not be members of struct or union types, again because the
> size isn't known until runtime, and the compiler can't know how much space
> to set aside for a particular struct or union instance.
>
> Whether space for the VLA is allocated on the stack or heap (or some other
> area) isn't specified; however, it's best to assume that VLAs are allocated
> like other auto variables, meaning the memory available for them is limited
> - if you need something that's more than a few kilobytes wide, use dynamic
> memory.
>
> You can mix VLAs with dynamic memory. Suppose you want to allocate a
> *contiguous* NxM array, but M isn't known until runtime. You could
> do something like the following:
>
> size_t cols = get_cols_from_somewhere();
> size_t rows = get_rows_from_somewhere();
>
> int (*arr)[cols] = malloc( sizeof ( int [cols] ) * rows );
> if ( arr )
> {
> // do something with arr[i][j]
> ...
> // finished, deallocate arr
> free( arr );
> }
>
> Normally I'd write "sizeof *arr" to get the size of the target, but
> strictly speaking that invokes undefined behavior for VLAs (even though I
> and a few others will argue that the standard is badly worded in that
> particular area).
Thanks John for the info!
[toc] | [prev] | [next] | [standalone]
| From | Tim Rentsch <txr@alumni.caltech.edu> |
|---|---|
| Date | 2017-01-30 05:21 -0800 |
| Message-ID | <kfna8a8heej.fsf@x-alumni2.alumni.caltech.edu> |
| In reply to | #102058 |
John Bode <jfbode1029@gmail.com> writes:
> [...]
> You can mix VLAs with dynamic memory. Suppose you want to allocate a
> *contiguous* NxM array, but M isn't known until runtime. You could
> do something like the following:
>
> size_t cols = get_cols_from_somewhere();
> size_t rows = get_rows_from_somewhere();
>
> int (*arr)[cols] = malloc( sizeof ( int [cols] ) * rows );
> [...]
Note that the argument to malloc() could also be written like
this:
int (*arr)[cols] = malloc( sizeof (int[rows][cols]) );
Between these two I find the second one easier to understand.
YMMV.
[toc] | [prev] | [standalone]
Page 8 of 8 — ← Prev page 1 2 3 4 5 6 7 [8]
Back to top | Article view | comp.lang.c
csiph-web