0

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;
    srand(time(0));
    for (A = 0; A < 50; ++A) {
       int number;

       number = rand();
       printf("%d\n");

  }
  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 :(
thanks

2
Contributors
2
Replies
5
Views
9 Years
Discussion Span
Last Post by satanix
0

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.
thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.