I have a problem interpreting the code. I know that scanf will pass stdin into the second argument, but in my case the second argument is the addition of two integers. What does this do?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
int *buffer;
int nextp=0,nextc=0;
int mutex,full,empty; /* semaphore variables
* mutex - binary semaphore -- critical section
* full, empty - counting semaphore */
void producer() {
int data;
if(nextp == N) //N has been defined as 3, but why? Probably, because they only want three iterations or processes to run.
nextp=0;
printf("\nEnter the data(producer) :");
//You're using scanf() to get userinput in C, like you're using std::cin in C++.
//"%d" for int ,"%f" for float ,"%e" for a scientific notation (1e10) ,"%c" for char , "%s" for strings.
scanf("%d",(buffer+nextp)); //second arg might need & to vars.
nextp++;
}