#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();
}
寫了一個時間表程序時,我完成的時間表。時間表在a.txt文件中創建。我希望打開該文件並自動顯示在記事本中。如何在c中編程?
打開另一個應用程序是平臺特定的。通常你會爲此操作一個OS API調用 – mbx
在標準C中沒有辦法做到這一點,你必須求助於一些特定於平臺的API(或利用'system'函數的平臺特定行爲)。你在哪個平臺上工作? –
@mbx如何找到要使用的API調用。我正在使用windows xp – ask22