C runtime errors are those errors that occur during the execution of a c program and generally occur due to some illegal operation performed in the program. Examples of some illegal operations that may produce runtime errors are: Dividing a … Continue reading
#include<stdio.h> #include<stdlib.h> int main() { char *pwd=NULL; char *buff=NULL; pwd=(char *)malloc(sizeof(char)*10); buff=(char *)malloc(sizeof(char)*10); int i=0,j,ret=0; int ch; FILE *fptr=NULL; printf(“enter the password”); scanf(“%s”,pwd); fptr=fopen(“file.txt”,”r”); if(fptr<0) { perror(“fopen”); return(-1); } ch=fgetc(fptr); for(j=0;j<3;j++) { while(ch!=EOF) { if(ch!=’\n’) { buff[i] = ch; i++; … Continue reading
#include<stdio.h> #include<sys/types.h> int main() { int i,n; pid_t pid; printf(“enter the no of child\n”); scanf(“%d”,&n); pid=fork(); for(i=1;i<n;i++) { if(pid>0) pid=fork(); } printf(“my id is->%d and my parent id is -> %d\n”,getpid(),getppid()); return 0; }
#include”header.h” #include”declaration.h” int main() { int ret,len,sum,sub,n; int r11[2]; int r12[2]; int r21[2]; int r22[2]; int p11[2]; int p12[2]; int p21[2]; int p22[2]; struct req rq; char br11[4],br12[4],br21[4],br22[4],bp11[4],bp12[4],bp21[4],bp22[4]; ret=pipe(r11); ret=pipe(r21); ret=pipe(r22); ret=pipe(r12); ret=pipe(p11); ret=pipe(p21); ret=pipe(p22); ret=pipe(p12); ret=fork(); if(ret == 0) … Continue reading
#include”header.h” #include”declaration.h” int main() { int r1,p1,ret,len; struct req res; ret=access(“rq1″,F_OK); if(ret <0) { ret=mkfifo(“rq1″,0777); if(ret<0) { perror(“mkfifo”); return -1; } } ret=access(“rq2″,F_OK); if(ret <0) { ret=mkfifo(“rq2″,0777); if(ret<0) { perror(“mkfifo”); return -1; } } ret=access(“rq3″,F_OK); if(ret <0) { ret=mkfifo(“rq3″,0777); if(ret<0) … Continue reading
Each element (we will call it a node) of a list is comprising of two items – the data and a reference to the next node. The last node has a reference to null. The entry point into a linked … Continue reading
#include<stdio.h> #include<string.h> #include<fcntl.h> int main() { int i,j,fd,len,maslen=1; char arr[100]={0}; char masterarr[25]={0}; fd=open(“add.c”,O_RDONLY); i=0; while(read(fd,&arr[i],1)) i++; len=strlen(arr); for(i=0;i<len;i++) { for(j=0;j<maslen;j++) { if(j+1==maslen) { masterarr[j]=arr[i]; maslen++; break; } else { if(masterarr[j]==arr[i]) break; } } } printf(“masterarr=%s\n”,masterarr); return 0; }