Skip to content

Commit

Permalink
Added screenshots. Also, added platform checks.
Browse files Browse the repository at this point in the history
Signed-off-by: Md Safiyat Reza <[email protected]>
  • Loading branch information
safiyat committed Jul 30, 2021
1 parent 4cef606 commit cfa2090
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ In case it is not, run
### For compilation
Run the compiler with the `lcurses` or `lncurses` switch to link against the curses library.

On mac: `gcc -lncurses main.c`

Ensure that you add the switch after the name of the C program. This is because object files and libraries are linked in order in a single pass.
Binary file added Screenshot One.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshot Two.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 12 additions & 4 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
#include<unistd.h>
#include<stdlib.h>
#include<stdio.h>
#include<stdio_ext.h>
#include<string.h>
#include<sys/shm.h>

#ifndef __APPLE__
#include<stdio_ext.h>
#else
#endif

#define SIZE 2048

struct user
Expand Down Expand Up @@ -36,8 +40,8 @@ int main()
usr[0]=usr[1]=(struct user *)NULL;
name=-1;

shmid[0]=shmget((key_t)1234, sizeof(struct user), 0666|IPC_CREAT);
shmid[1]=shmget((key_t)4321, sizeof(struct user), 0666|IPC_CREAT);
shmid[0]=shmget((key_t)12345, sizeof(struct user), 0666|IPC_CREAT);
shmid[1]=shmget((key_t)54321, sizeof(struct user), 0666|IPC_CREAT);

if(shmid[0]==-1||shmid[1]==-1)
{
Expand Down Expand Up @@ -79,7 +83,11 @@ int main()
}

printf("\nEnter your username: ");
#ifndef __APPLE__
__fpurge(stdin);
#else
fpurge(stdin);
#endif
scanf("%s", buf);
strncpy(usr[me]->usrname, buf, 15);
usr[me]->state=23;
Expand Down Expand Up @@ -230,7 +238,7 @@ int main()
usr[me]->state=3;
endwin();

if((usr[me]->state==3))
if(usr[me]->state==3)
{
if((shmdt(shm[0])==-1)||(shmdt(shm[1])==-1))
{
Expand Down

0 comments on commit cfa2090

Please sign in to comment.