Showing posts with label Deleting the number of lines without using other files. Show all posts
Showing posts with label Deleting the number of lines without using other files. Show all posts

Tuesday, February 1, 2011

Deleting the number of lines without using other files



/*
 * DeleteTrace.c
 *
 *  Created on: Feb 1, 2011
 *      Author: Karthikeyan.D
 */
# include <stdio.h>
# include <conio.h>
# include <windows.h>
# include <stdlib.h>

int main()
{
    // Variable Declaration
    FILE *FRead,*FWrite;
    char SzContent[1000];
    long int nloop;
    long int nLineIndex;
    /* File read and Read/write Mode Operation*/
    // Here You Can Your File Location.

    printf("Enter file File Path \n");
    gets(SzContent);

    FRead = fopen(SzContent,"r");

    FWrite = fopen(SzContent,"r+");
    if(FRead == NULL)
    {
        MessageBox(NULL,"Please Specify Already Created File Location ","Error in File Location",16);
        exit(0);
    }

    printf("Enter the Line Index \n");
    scanf("%ld",&nLineIndex);

    /* This function is used to remove the number lines*/
    for (nloop=0;nloop<nLineIndex;nloop++)
    {
        fgets(SzContent,1000,FRead);
    }
    /* This function is used to overwrite content from the top of the line*/
    while(fgets(SzContent,1000,FRead)!=NULL)
    {
        fprintf(FWrite,SzContent);
    }
    /* To close the Two File Pointer */
    fclose(FRead);
    fclose(FWrite);

    getch();
    return 0;
}