@angala wrote:
/* nl command Program#225 */ #include<stdio.h> main(int argc,char *argv[]) { int i,j,p,h; char a[200]; if(argc!=2) { printf("error: no.of arg"); return 0; } p=open(argv[1], 0); if(p==-1) { printf("file open error"); return 0; } for(j=0,n=0;(i=read(p,&a[j],1))>0;j++) { if(a[j]=='\n') { n++; a[j]='\0'; printf("%d %s", n,a); j=-1; } } close(p); }
Posts: 1
Participants: 1