Skip to main content

Posts

Showing posts from June 8, 2014

Write a c program using system calls to display content of file.

/* Write a c program using system calls to display content of file. Kindly add header files like :stdio.h,sys/types.h,   sys/stat.h, unistd.h,string.h,fcntl.h  */ int main(int argc, char *argv[]) {         int fd=0,r=0,i=0;         char buf[1024];         if(argc >= 2)         {         for(i=1;i         {                 fd=open(argv[i],O_RDONLY);                 if(fd == -1)                 {                         printf("file not exist");                 }   else                 {                 while((r=read(fd,buf,1024))>0)                         write(1,buf,r);                 }         }         }         else         {                 printf("enter appropriate arguments");         }         return 0; }

Write A C Program To Create A File And Write Something in it using System Calls.

/*Write A C Program To Create A File And Write Something in it using System Calls.*/ #include #include #include #include #include #include int main(int argc ,char *argv[]) {         int i=0,fd;         for(i=1;i         {                 fd=creat(argv[i],S_IREAD|S_IWRITE);                 write(fd,"file created",12);                 write(1,"file created\n",13);                 close(fd);         }         return 0; } See Also: Write any C program using write() system call. Write shell script that do equivalent to cut–c 5-10 utility Write C program that display name of all empty file and remove from directory.

Write shell script that do equivalent to cut–c 5-10 utility

#Write shell script that do equivalent to cut–c 5-10 utility. echo "Script Name : $0" i=0 lines=`cat $1 | wc -l` echo "No of lines in file named $1 : $lines" while [ $i -ne $lines ] do line=`head -$i $1 | tail -1` #echo $line #cutline= `echo expr substr "$line" 5 10` cutline=`echo $line | tail -c +5 | head -c 5` echo $cutline i=`expr $i + 1` #echo $i done echo "Done" See Also : Write C program that display name of all empty file and remove from directory.

Write C program that display name of all empty file and remove from directory.

/* Write C program that display name of all empty file and remove from directory   */ #include #include #include int main() { DIR *dp=opendir("."); struct dirent *files; struct stat stbuf; int siz=0,cnt=0; while((files=readdir(dp))!=NULL) { if(lstat(files->d_name,&stbuf)==-1) { printf("cant link"); } else { if(S_ISREG(stbuf.st_mode)) { siz=(int)stbuf.st_size; if(siz==0) { printf(" %s is empty file of size= %d \n",files->d_name,siz); //remove(files->d_name); unlink(files->d_name); cnt++; } } } } printf("\n number of empty file %d",cnt); return 0; }

Some Useful Short Cut Keys & Combinations To Work Fast

Keyboard Shorcuts (Microsoft Windows) 1. CTRL+C (Copy) 2. CTRL+X (Cut) 3. CTRL+V (Paste) 4. CTRL+Z (Undo) 5. DELETE (Delete) 6. SHIFT+DELETE (Delete the selected item permanently without placing the item in the Recycle Bin) 7. CTRL while dragging an item (Copy the selected item) 8. CTRL+SHIFT while dragging an item (Create a shortcut to the selected item) 9. F2 key (Rename the selected item) 10. CTRL+RIGHT ARROW (Move the insertion point to the beginning of the next word) 11. CTRL+LEFT ARROW (Move the insertion point to the beginning of the previous word) 12. CTRL+DOWN ARROW (Move the insertion point to the beginning of the next paragraph) 13. CTRL+UP ARROW (Move the insertion point to the beginning of the previous paragraph) 14. CTRL+SHIFT with any of the arrow keys (Highlight a block of text) SHIFT with any of the arrow keys (Select more than one item in a window or on the desktop, or select text in a document) 15. CTRL+A (Select all) 16.

Failure is not an option

Failure is not an option. It's bundled with your software.