矩阵输出无结果
为什么程序运行总是:按任意键继续#include<stdarg.h>
#include<stdio.h>
void MyBreak(char * fmt,...)
{
char buffer[256];
va_list argptr;
va_start(argptr,fmt);
vsprintf(buffer,fmt,argptr);
va_end(argptr);
#ifdef VC_EXTRALEAN
AfxMessageBox(buffer);
#else
printf(buffer);
getchar();
#endif//VC_EXTRALEAN
}
void printm(FILE *fp,double m[][3],int n,char *fmt,char *title,bool IsLable)
{
if(title)fprintf(fp,"\n%s:",title);
for(int i=0;i<n;i++)
{
if(IsLable)fprintf(fp,"\n%3d",i+1);else fprintf(fp,"\n ");
for(int j=0;j<=i;j++) fprintf(fp,"%f",m[i][j]);
}
}
void main()
{
double a[][3]={{1.0,0.0,-1.0},{0.0,2.0,4.0},{-1.0,4.0,5.0}};
FILE *fp=fopen("2.txt","r");
if(fp==NULL)
{
MyBreak("结果输出文件打不开!");
return;
}
printm(fp,a,3,"%8.3lf","a矩阵",true);
fclose(fp);
}