#include <stdio.h>
#include "headfork.h"// included in attachment
#include "headsem.h"
#include "headshr.h"
main()
{
int id,i,sid1,sid2,nprc;
char *str;
int *cnt,s,*lock;
cnt=(int *)shared(sizeof(int)*2,&sid1);
lock=(int *)shared(sizeof(int)*2,&sid2);
str=(char *)malloc(20);
for(i=0;i<20;i++)
str[i]='\0';
lock_init(lock);
printf("Enter any String :");
scanf("%s",str);
printf("Enter no. of proc:");
scanf("%d",&nprc);
id=p_fork(nprc);
s=0;
for(i=id;*(str+i)!='\0';i+=nprc)
{
if(*(str+i)>=65 && *(str+i)<=90 || *(str+i)>=97 && *(str+i)<=122)
s=s+1;
}
locksem(lock);
*cnt=*cnt+s;
unlock(lock);
p_join(nprc,id);
printf("No. of characters are : %d",*cnt);
}