Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I call notepad.exe from a C program?

i have written a time table program in c

#include<stdio.h> 
#include<conio.h> 
void main()
{
  int i=0;
  int selection;
  char day[20];
  char sub1[20];
  char sub2[20];
  char sub3[20];
  FILE *fp;
  fp=fopen("aa.txt","w");
  textcolor(5);
  textbackground(3);
  clrscr();
  while(i<3)
  {
    printf("Enter the day ");
    scanf("%s",day);
    printf("Enter the period 12.30-1:30 ");
    scanf("%s",sub1);
    printf("Enter the period 1.35-2.40 ");
    scanf("%s",sub2);
    printf("Enter the period 2.45-3.50 ");
    scanf("%s",sub3);
    fprintf(fp,"\n %s TIMETABLE IS AS FOLLOWS\n",day);
    fprintf(fp,"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
    fprintf(fp,"|~~~~~~~~~|~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~|~~~~~~~~~~|\n");
    fprintf(fp,"| TIME    | 12.30-1.30    | 1.35-2.40    |2.45-3.50 |\n");
    fprintf(fp,"|~~~~~~~~~|~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~|~~~~~~~~~~|\n");
    fprintf(fp,"| SUBJECT *     %s     * %s  * %s|\n",sub1,sub2,sub3);
    fprintf(fp,"|~~~~~~~~~|~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~|~~~~~~~~~~|\n");
    i++;
  }
  printf(" Time table has been Created in the File aa.txt successfully");
  getch();
}

when i finish the timetable . the time table is created in a.txt file. i want that file to be opened and show me automatically in a notepad. how to program that in c?

like image 309
ask22 Avatar asked Aug 14 '11 13:08

ask22


1 Answers

Use

system("notepad.exe aa.txt");
like image 156
Dani Avatar answered Oct 17 '22 10:10

Dani