Showing posts with label clrscr. Show all posts
Showing posts with label clrscr. Show all posts

C Program To Copy The Contents Of One File Into Another Using fputc

#include<stdio.h>
#include<process.h>

void main()
{
FILE *fp1,*fp2;
char a;
clrscr();

fp1=fopen("test.txt","r");
if(fp1==NULL)
    {
    puts("cannot open this file");
    exit(1);
    }

fp2=fopen("test1.txt","w");
if(fp2==NULL)
    {
    puts("Not able to open this file");
    fclose(fp1);
    exit(1);
    }

   do
    {
    a=fgetc(fp1);
    fputc(a,fp2);
    }while(a!=EOF);

fcloseall();
getch();
}

C Program to Print Date

/* C Program Example - C Program to Print Date 
*  This C program will print the current date */

#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main()
{
clrscr();
struct date d;
getdate(&d);
printf("Current system date is %d/%d/%d",d.da_day, d.da_mon, d.da_year);
getch();
}