C Programming Tutorial


Advanced Programming


One dimensional array Two dimensional Array Two dimensional array pointers Array of pointers Print array Print Array - for loop Print array in reverse Print address array - for loop Multidimentional array - function Print address array - pointers Print reverse string of array Print array ascii value-without atoi Character array - upper case Multiplication table - 2D array Passing array to function Max or greatest value in array Merge sorted array Array of structure Array of pointers to string Array within a structure

String Programs

Copy string Substring of string String concatination Vowel in string Swap char in string Palindrome string Rotate string Bubble sort of strings Sorting of words Encode decode string Compress string

File Programs

Read write in 2 files Add,edit,delete,search in file Add,search using structure Append in file Merge file Count word,line,char in file Count record - struct fread() example fwrite() example fopen() example fclose() example fscanf() and fprintf() fseek() example Error handling in file op Find odd,even num Odd even numbers in file Max, min age in class Random numbers file Preprocessor in 2 files Encode decode in file

Bios Programming

biosequip( ) - sys confi biosdisk( ) - partition tbl info Pc type-bios data area File allocation table Telephone directory

TSR Programming

Interchange letters Interchange letters on screen Unload TSR on key press-keyboard Unload TSR - timer interrupt Activate, deactivate TSR Print alphabet from printer Repeat key press Keep caps on Make ctrl, alt key pressed

Interrupt Programming

Restart computer Conventional memory of sys Save IVT in file Print string-interrupt 21h Read char-interrupt 21h Read char with echo-interrupt 21h Delete file-interrupt 21h Delete directory-interrupt 21h Get set system date Show system configuration Search, delete file in dir Display multiple file in dir

Mouse Programming

Text mode mouse handling Graphics mode mouse handling Double click of mouse
#include  <stdio.h>                                              

   struct invent_record                                             
       char   name[10];                                             
       int    number;                                               
       float  price;                                                
       int    quantity;                                             

       struct invent_record item;                                   
       char  filename[10];                                          
       int   response;                                              
       FILE  *fp;                                                   
       long  n;                                                     
       void append (struct invent_record 8x, file *y);                                                             
       printf(\"Type filename:\");                                    
       scanf(\"%s\", filename);                                       

       fp = fopen(filename, \"a+\");                                  
          append(&item, fp);                                        
          printf(\"\\nItem %s appended.\\n\",item.name);                
          printf(\"\\nDo you want to add another item\\                
           (1 for YES /0 for NO)?\");                                        
          scanf(\"%d\", &response);                                   
       }  while (response == 1);                                    

       n = ftell(fp);      /* Position of last character  */        

       fp = fopen(filename, \"r\");                                   

  while(ftell(fp) < n)                                         
          fscanf(fp,\"%s %d %f %d\",                                  
          item.name, &item.number, &item.price, &item.quantity); 
          fprintf(stdout,\"%-8s %7d %8.2f %8d\\n\",                    
          item.name, item.number, item.price, item.quantity);    
   void append(struct invent_record *product, File *ptr)
       printf(\"Item name:\");                                        
       scanf(\"%s\", product->name);                                  
       printf(\"Item number:\");                                      
       scanf(\"%d\", &product->number);                               
       printf(\"Item price:\");                                       
       scanf(\"%f\", &product->price);                                
       scanf(\"%d\", &product->quantity);                             
       fprintf(ptr, \"%s %d %.2f %d\",                                

   Type filename:INVENTORY                                          
   Item name:XXX                                                    
   Item number:444                                                  
   Item price:40.50                                                 
   Item XXX appended.                                               
   Do you want to add another item(1 for YES /0 for NO)?1           
   Item name:YYY                                                    
   Item number:555                                                  
   Item price:50.50                                                 
   Item YYY appended.                                               
   Do you want to add another item(1 for YES /0 for NO)?0           
   AAA-1        111    17.50      115                               
   BBB-2        125    36.00       75                               
   C-3          247    31.75      104                               
   XXX          444    40.50       34                               
   YYY          555    50.50       45                               

Didn't find what you were looking for? Find more on APPENDING ITEMS TO AN EXISTING FILE USING DO WHILE LOOP