From: Wol's lists <antlists@youngman.org.uk>
To: mdraid <linux-raid@vger.kernel.org>
Subject: [OT] C programming problem
Date: Wed, 7 Feb 2018 19:46:13 +0000 [thread overview]
Message-ID: <2a2e28ad-20bd-d369-d65f-19d79f1871fb@youngman.org.uk> (raw)
It is for raid, honest :-)
My C is so rusty it's jammed solid :-) but I'm trying to prototype a
simple algorithm for "de-clustering" a raid-60/61 array.
Googling for my error -
main.c:20:5: warning: incompatible implicit declaration of built-in
function ‘memset’ [enabled by default]
memset( &array, 0, blocks * sizeof(int) );
says "you need to include stdlib.h" - but I have!
(I'm getting the same error on the malloc ...)
#include <stdio.h>
#include <stdlib.h>
void main()
{
int disks, logdisks, mirrors, prime;
printf( "%s", "Enter the number of disks ");
scanf( "%d", &disks);
printf( "%s", "Enter the number of logical disks ");
scanf( "%d", &logdisks);
printf( "%s", "Enter the number of mirrors ");
scanf( "%d", &mirrors);
printf( "%s", "Enter the prime ");
scanf( "%d", &prime);
int blocks, *array;
blocks = logdisks * mirrors * disks;
array = (int *) malloc( sizeof(int) * blocks );
memset( &array, 0, blocks * sizeof(int) );
int i;
for (i=0; i < blocks; i++) {
array[i] = (i * prime) % blocks;
}
for (i=0; i < blocks; i++) {
if ( (i % disks) == 0)
printf( "\n");
printf( "%4d", array[i]);
}
}
next reply other threads:[~2018-02-07 19:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 19:46 Wol's lists [this message]
2018-02-07 20:00 ` [OT] C programming problem Linus Lüssing
2018-02-07 20:00 ` Michael Fritscher
2018-02-07 20:22 ` Wol's lists
2018-02-07 22:43 ` Phil Turmel
2018-02-07 23:32 ` Wol's lists
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2a2e28ad-20bd-d369-d65f-19d79f1871fb@youngman.org.uk \
--to=antlists@youngman.org.uk \
--cc=linux-raid@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox