hello i have got little problem :)
create a c program which starts with 3 processes the first proccess generates 50 random numbers and writes them inti common memory. the second proccess reads them and whrites the even numbers in file A,the odd numbers in file B.

#include <stdlib.h>
#include <stdio.h>

int main(void)
    int A;
    for (A = 0; A < 50; ++A) {
       int number;

       number = rand();

  return 0;

i create first part of the program i also know how to find odd and even numbers

if ( x % 2 == 0 ) { //even
} else { /odd

i know that i must insert "fd = open("blabla",O_RDWR|O_CREAT,0)" after "if" but my knowlodge isnt enogh :(

don't use open(), instead use fopen() because FILE* and associated functions are much easier to use.

Here is a file i/o tutorial

thanks for answer and tutarial page i read all of them fopen seems better then open.At the code which i wrote it finds 50random numbers but i dont know how to find old or even numbers and write them to 2 different file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.