Kapsu
10th October 2014, 07:10
Hi! Newbie here.
I was working on a C project before using Ubuntu, but now I have switched to Windows7 and want to continue my work. I got Qt Creator and was thinking that this would solve all my problems... All I would have to do is start a "plain C project" and copy whatever I had previously. Everything else is going great, except for one thing: the program cannot create data files. Does this mean that the old "FILE" command from C doesn't work in Qt Creator? Or is this possibly some sort of problem with permissions to access files that Qt has?
I read from other threads that there is some sort of "Qt FILE" command to create files, but I want to make sure whether I would be able to use FILE command from C language to create files or not. I could not find an answer with the search button, so I might have been using the wrong keywords..
Also, here is the part of my code that handles the file-making. If there is some way to make it work, I'd like to hear it. :)
void save_file(np,xp,yp,up,vp,rax,ray,tp,dp,mp,fname,ti me,fn)
int np,time,fn;
double *xp,*yp,*up,*vp,*rax,*ray,*tp,*dp;
int *mp;
char fname[];
{
FILE *fp;
int i,k;
char fname_full[200];
sprintf(fname_full,"%s_nor.%05d",fname,fn);
fp=fopen(fname_full,"wt");
if(fp==NULL) {printf("\n Cannot create file1 %s \n",fname_full);exit(1);}
fprintf(fp,"%d\n",np);
for(k=0;k<np;k++)
fprintf(fp,"%lf %lf %7.6e %7.6e %lf %lf %d\n",xp[k],yp[k],up[k],vp[k],tp[k],dp[k],mp[k]);
if(fclose(fp)==EOF)
{printf("\n Error in closing file %s \n",fname_full);exit(1);}
}
I was working on a C project before using Ubuntu, but now I have switched to Windows7 and want to continue my work. I got Qt Creator and was thinking that this would solve all my problems... All I would have to do is start a "plain C project" and copy whatever I had previously. Everything else is going great, except for one thing: the program cannot create data files. Does this mean that the old "FILE" command from C doesn't work in Qt Creator? Or is this possibly some sort of problem with permissions to access files that Qt has?
I read from other threads that there is some sort of "Qt FILE" command to create files, but I want to make sure whether I would be able to use FILE command from C language to create files or not. I could not find an answer with the search button, so I might have been using the wrong keywords..
Also, here is the part of my code that handles the file-making. If there is some way to make it work, I'd like to hear it. :)
void save_file(np,xp,yp,up,vp,rax,ray,tp,dp,mp,fname,ti me,fn)
int np,time,fn;
double *xp,*yp,*up,*vp,*rax,*ray,*tp,*dp;
int *mp;
char fname[];
{
FILE *fp;
int i,k;
char fname_full[200];
sprintf(fname_full,"%s_nor.%05d",fname,fn);
fp=fopen(fname_full,"wt");
if(fp==NULL) {printf("\n Cannot create file1 %s \n",fname_full);exit(1);}
fprintf(fp,"%d\n",np);
for(k=0;k<np;k++)
fprintf(fp,"%lf %lf %7.6e %7.6e %lf %lf %d\n",xp[k],yp[k],up[k],vp[k],tp[k],dp[k],mp[k]);
if(fclose(fp)==EOF)
{printf("\n Error in closing file %s \n",fname_full);exit(1);}
}