RCS file: ./linklist1.c,v Working file: ./linklist1.c head: 1.1 branch: locks: strict root: 1.1 access list: symbolic names: keyword substitution: kv total revisions: 1; selected revisions: 1 description: make a struct for linklist and defined three pointers start,prev,end . data store … Continue reading
RCS file: ./open.c,v Working file: ./open.c head: 1.1 branch: locks: strict root: 1.1 access list: symbolic names: keyword substitution: kv total revisions: 1; selected revisions: 1 description: make and upgrade ls command use of alphasort() func ,also count the entries … Continue reading
1 #include<stdio.h> 2 #include<stdlib.h> 3 4 int stcmp(char *str1 ,char *str2) 5 { 6 int dif,i=0; 7 while(str1[i]!=”||str2[i]!=”) 8 { 9 dif=(str1[i]-str2[i]); 10 if(dif!=0) 11 { 12 break; 13 } 14 i++; 15 } 16 if(dif>0) 17 { 18 printf(“-%d”,dif); … Continue reading
1 #include<stdio.h> 2 #include<stdlib.h> 3 char* ip() 4 { 5 char *s1,ch; 6 int i=0; 7 s1=(char*)malloc(sizeof(char)); 8 while(1) 9 { 10 scanf(“%c”,&ch); 11 s1=realloc(s1, i+1*sizeof(char)); 12 if(ch==10) 13 break; 14 s1[i]=ch; 15 i++; 16 } 17 printf(“%s\n”,s1); 18 return … Continue reading
#include #include char *input(); int length(char *); int main() { char *s1,*s2; int i; printf(“Enter string 1:”); s1=input(); printf(“Enter string 2:”); s2=input(); i=length(s1); printf(“Length of string is:%d\n”,i); } char *input() { char *s,ch; int i=0; s=(char *)malloc(sizeof(char)); while(1) { scanf(“%c”,&ch); … Continue reading
#include<stdio.h> #include<fcntl.h> #include<dirent.h> #include<string.h> int openf(char *); int main() { DIR *i; struct dirent *k; int j,l,s,flag=1,fd,fd1; char *m = “txt.”; char ch; fd1 = openf(“new.txt”); i = opendir(“./test”); printf(“\n%d\n”,i); while(( k = readdir(i)) != NULL) { flag=1; l=strlen(k->d_name); for(j … Continue reading
#include<stdio.h> #include<fcntl.h> #include<stdlib.h> int foo(int , char *, int , int , int, char *); int openf( char *); int main(int argc, char * argv[]) { int fd,pos,skip,b_size,n; char ch,*buff; buff = (char*)malloc(sizeof(char)); printf(“\nBlock size: “); scanf(“%d”,&b_size); printf(“\nNumber of Blocks: … Continue reading
#include<stdio.h> #include<fcntl.h> int openf(char *); int main(int argc, char * argv[]) { int fd,fd1, pos,i=1000000; char ch=”; fd = openf(argv[1]); pos = lseek(fd,i * 4096, SEEK_SET); write(fd, &ch,1); close(fd); } int openf(char * s) { int fd; fd = open(s,O_RDWR|O_CREAT,0666); … Continue reading
#include<stdio.h> #include<fcntl.h> int openf(char *); int main(int argc, char * argv[]) { int fd,fd1, pos,i=3; char ch; fd = openf(argv[1]); fd1 = openf(argv[2]); pos = lseek(fd, 0, SEEK_END); printf(“\n%d\n”,pos); for(i=2; i < pos+1;i++) { lseek(fd, pos-i, SEEK_SET); read(fd, &ch, 1); … Continue reading
RCS file: fops.h,v Working file: fops.h head: 1.1 branch: locks: strict root: 1.1 access list: symbolic names: keyword substitution: kv total revisions: 1; selected revisions: 1 description: struct file_operations fops={ 2 open:device_open, 3 release:device_release, 4 write:write, 5 read:read, 6 llseek:llseek … Continue reading
#include<stdio.h> int main() { int i,j,n,small,k; printf(“Enter the Element of Array\n”); scanf(“%d”,&n); int a[n]; printf(“Enter the element\n”); for(i=0;i<n;i++) { scanf(“%d”,&a[i]); } for(i=0;i<n;i++) { small=i; for(j=i;j<n;j++) { if(a[j]<a[small]) small=j; } k=a[small]; a[small]=a[i]; a[i]=k; } for(i=0;i<n;i++) { printf(“%d\n”,a[i]); } }
#include<stdio.h> int main() { int i,j,n,temp,search,low,high,mid,c; printf(“Enter the element of array \n “); scanf(“%d”,&n); int a[n]; printf(“Enter the element\n”); for(i=0;i<n;i++) { scanf(“%d”,&a[i]); } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { if(a[i]>a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; } } } printf(“Array After Shorting\n”); for(i=0;i<n;i++) { … Continue reading
#include”header1.h” struct distance *input() { struct distance *d1; d1=(struct distance *)malloc(sizeof(struct distance)); printf(“\nenter the distance in feet”); scanf(“%d”,&d1->feet); printf(“\nenter the distance in inches”); scanf(“%f”,&d1->inches); return d1; } struct distance *add(struct distance *d1, struct distance *d2) { struct distance *d4; d4=(struct … Continue reading
—test——– #! /bin/bash rcs -i header.h rcs -i llist_ato_sir.c ci header.h ci llist_ato_sir.c co header.h co llist_ato_sir.c gcc -o result llist_ato_sir.c ./result rm -rf header.h rm -rf llist_ato_sir.c rm -rf result //——-header file—— @#include #include struct link { int info; … Continue reading
#include #include int main() { char a[20]={0},b[10]={0}; int i,j=0; printf(“Enter name1:\n”); scanf(“%s”,a); printf(“Enter second name:\n”); scanf(“%s”,b); for(i=0;i<20;i++) { if(a[i]=='') { a[i]=b[j]; j++; } } printf("Concatination is: %s\n",a); return 0; }