Path: ...!news.mixmin.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: rbowman Newsgroups: comp.os.linux.advocacy Subject: Re: More Funny Stuff From Joel Date: 13 Jun 2024 22:16:24 GMT Lines: 28 Message-ID: References: <17d716103c089ab3$7951$675878$802601b3@news.usenetexpress.com> <2ej96j1mbvgiok4q5c57vdlo94itpfu5dt@4ax.com> <6664e989$0$2363151$882e4bbb@reader.netnews.com> <66687931$0$3747328$882e4bbb@reader.netnews.com> <66699f8c$0$966$882e4bbb@reader.netnews.com> <666b0963$0$985$882e4bbb@reader.netnews.com> <666b43c2$0$966$882e4bbb@reader.netnews.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net OfwjAYbR8m4KZPu85InEOA6AS2cGXDMGngT7hqEtOy1OuEzoQv Cancel-Lock: sha1:2cYnQnUxjhnbRL7AA8ii2eSXlcg= sha256:z/fKUg8UpEqW5BwpNsYJY2KEalpIMSZuYi6IiRpaffw= User-Agent: Pan/0.149 (Bellevue; 4c157ba) Bytes: 2565 On Thu, 13 Jun 2024 15:08:50 -0400, DFS wrote: > - malloc the md_count[] array to size 9 (because there > are only 9 unique values in the size 10 dataset) What memory location is md_count[9]++ incrementing? For that matter what are the initial values of md_count[0] through md_count[8] ? I used memset(&md_count, 0, sizeof md_count); with the original declaration or you could have used calloc(). Same difference. You wind up with something that's not an array of whatever random crap is on the stack. > - add return 0 picky, picky... I suppose you want 'int main(void)' too. I can't remember the guy's name but he was a prolific author of programming books in the early '80s whose examples always started with 'void main(). If comments in programming forums could kill he would have had an early retirement. Not for nothing but in VS Code if you don't initialize 'mode' at the point where it's used there is a red squiggle that pops up 'identifier "mode" is undefinedC/C++(20)' It doesn't flag an uninitialized 'mean', although 'mean += nums[len];' assumes it was 0.0. Points to clang for that one.