Hi newsgroup
The program here given is refused by GCC with a error i cannot
understand. It says
rnd00.c: In function ‘main’:
rnd00.c:26: error: expected expression before ‘]’ token
How to make it compile? I also tried buf[10] but that gives "segmentati on
fault". Thanks in advanced.
/* scanf 10 random integers from /dev/random */
#include <stdio.h>
void open_file(FILE *f)
{
f= fopen("/dev/random", "r");
}
void read_values(FIL E *f, int buf[], int count)
{
do
{
--count;
fread((void*)&b uf[count], sizeof(int), 1, f);
}
while(count 0);
}
int main()
{
int buf[10];
int count= 10;
FILE *f;
open_file(f);
read_values(f, buf[], count);
do
{
--count;
printf("%d ", buf[count]);
}
while(count 0);
return 0;
}
--
Kapteyn's Star
The program here given is refused by GCC with a error i cannot
understand. It says
rnd00.c: In function ‘main’:
rnd00.c:26: error: expected expression before ‘]’ token
How to make it compile? I also tried buf[10] but that gives "segmentati on
fault". Thanks in advanced.
/* scanf 10 random integers from /dev/random */
#include <stdio.h>
void open_file(FILE *f)
{
f= fopen("/dev/random", "r");
}
void read_values(FIL E *f, int buf[], int count)
{
do
{
--count;
fread((void*)&b uf[count], sizeof(int), 1, f);
}
while(count 0);
}
int main()
{
int buf[10];
int count= 10;
FILE *f;
open_file(f);
read_values(f, buf[], count);
do
{
--count;
printf("%d ", buf[count]);
}
while(count 0);
return 0;
}
--
Kapteyn's Star
Comment