C Programming Tutorial

 
 
 

Advanced Programming

Array

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 <string.h>
 # include  <stdio.h>
 # include  <conio.h>
 # include    <dos.h>
 # include    <dir.h>


 void FindFile(const char* Path,const char* FileName);

 const int DeleteFile(const char* File);

 int main( )
 {
    int count;
    int cur_drive=getdisk( );
    int total_drives=setdisk(2);

    char Drive[10]={\"C:\\\\\"};
    char FileName[15]={NULL};
    char CurrentDirectory[MAXPATH]={NULL};

    clrscr( );

    getcwd(CurrentDirectory,MAXPATH);

    printf(\"Enter the File Name to delete: \");
    scanf(\"%s\",FileName);

    printf(\"\\nSearching....\\n\\n\");

    for(count=2;count<total_drives;count++)
    {
       setdisk(count);

       if(count==getdisk( ))
       {
      Drive[0]=(65+count);

      FindFile(Drive,FileName);
       }
    }

    setdisk(cur_drive);
    chdir(CurrentDirectory);

    printf(\"\\nPress any key to exit...\");

    getch( );
    return 0;
 }


 //----------------------------  FindFile( )  ----------------------------//


 void FindFile(const char* Path,const char* FileName)
 {
    struct find_t ffblk;

    int flag;

    char File[MAXPATH]={NULL};

    chdir(Path);

    strcpy(File,Path);
    strcat(File,FileName);

    flag=_dos_findfirst(File,_A_NORMAL,&ffblk);

    if(!flag)
    {
       char Choice;

       while(!flag)
       {
      printf(\"File Found:: %s%s\\n\",Path,ffblk.name);
      printf(\"Do you want to delete it? (Y/N) : \");

      Choice=getche( );

      if(Choice==\'Y\' || Choice==\'y\')
      {
         char Temp[MAXPATH]={NULL};

         strcpy(Temp,Path);
         strcat(Temp,ffblk.name);

         if(DeleteFile(Temp))
         {
        printf(\"Unable to delete the specified file.\");

        getch( );
         }
      }

      printf(\"\\n\\n\");

      flag=_dos_findnext(&ffblk);
       }
    }

    strcpy(File,Path);
    strcat(File,\"*.*\");

    flag=_dos_findfirst(File,FA_DIREC,&ffblk);

    while(!flag)
    {
       if(strcmp(ffblk.name,\".\")!=0 && strcmp(ffblk.name,\"..\")!=0 &&
                              ffblk.attrib==FA_DIREC)
       {
      char Temp[MAXPATH]={NULL};

      strcpy(Temp,Path);
      strcat(Temp,ffblk.name);
      strcat(Temp,\"\\\\\");

      FindFile(Temp,FileName);
       }

       flag=_dos_findnext(&ffblk);
    }

    chdir(Path);
 }


 //---------------------------  DeleteFile( )  ---------------------------//


 const int DeleteFile(const char* File)
 {
    union REGS InReg;
    union REGS OutReg;

    InReg.h.ah=0x41;
    InReg.x.dx=FP_OFF(File);

    int86(0x21,&InReg,&OutReg);

    return OutReg.x.cflag;
 }

    Related Post:
  1. Comparing and copying structure variables

  2. Program to compute sum of those integers that are evenly divisible by 5. Use the conditional operator ( ? : )

  3. Example 2 to display array values and address of an array using pointers

  4. Program to calculate area of rectangle and circle

  5. Program to add a new node to the asscending order linked list

  6. Program to read the following numbers,round them off to the nearest integers and print out the results in integer form: 35.7 50.21 -23.73 -46.45

  7. Program to display floyds triangle

  8. Program to find ascii value of entered text or word for each character

  9. PROGRAM TO READ NUMBERS, N1 AND N2 ARE INTERCHANGE WITHOUT USING EXTRA VARIABLES.N1=10, N2=20 THEN O/P IS N1=20, N2=10 USING MULTIPLICATION, DIVISION

  10. Program to print multiplication table using two-dimensional array

  11. PROGRAM THAT WILL PRINT YOUR MAILING ADDRESS IN THE FOLLOWING FORM: FIRSTLINE:- NAME, SECOND LINE:-DOOR NO. STREET, THIRD LINE:-PIN CODE

  12. Program to calculate average of numbers given by user using while loop

  13. Program illustrates the use of scanf funtion

  14. Program that converts hexadecimal value in decimal, octal and binary.

  15. PROGRAM TO FIND CORRELATION BETWEEN TWO ARRAYS USING BARRIER AND LOOP-SPLITTING

  16. Program of FIXED POINT METHOD OF NON LINEAR EQUATION

  17. Program to create a singly linked list of numbers using threads

  18. Implement a multi-access threaded queue with multiple threads inserting and multiple threads extracting from the queue

  19. Program to convert binary to octal

  20. Program to print string in different pattern