Open a file Using C


program 

#include<stdio.h>
#include<conio.h>
void main(void)
{
        FILE*fptr;
        fptr=fopen("Amin.txt","w");
        int a,b;
        char d;
        printf("\n Enter a Name:");
        scanf("%c",&d);
        fprintf("\n Name  %c",d);
        fclose(fptr);
}

OUTPUT


Enter a Name:khalid
file is open with the name of Amin and khalid is written inside the file

NOTE:

FILE*fptr

it is use point a file or call a file it stand for (pointer to file)

fptr=fopen("Amin.txt","w");

it is use to open a file

 fprintf

it is use to write in the file

Comments

Popular posts from this blog

Stack

Operation on Single Linked List

EXTRA INFORMATION ABOUT TECHNOLOGY