Results 1 to 5 of 5

Thread: Creating files using plain C project in Qt Creator (command FILE)

  1. #1
    Join Date
    Oct 2014
    Posts
    3
    Qt products
    Qt3

    Question Creating files using plain C project in Qt Creator (command FILE)

    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. :)

    Qt Code:
    1. void save_file(np,xp,yp,up,vp,rax,ray,tp,dp,mp,fname,time,fn)
    2. int np,time,fn;
    3. double *xp,*yp,*up,*vp,*rax,*ray,*tp,*dp;
    4. int *mp;
    5. char fname[];
    6. {
    7. FILE *fp;
    8. int i,k;
    9. char fname_full[200];
    10.  
    11. sprintf(fname_full,"%s_nor.%05d",fname,fn);
    12. fp=fopen(fname_full,"wt");
    13. if(fp==NULL) {printf("\n Cannot create file1 %s \n",fname_full);exit(1);}
    14.  
    15. fprintf(fp,"%d\n",np);
    16. for(k=0;k<np;k++)
    17. 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]);
    18.  
    19. if(fclose(fp)==EOF)
    20. {printf("\n Error in closing file %s \n",fname_full);exit(1);}
    21.  
    22. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Creating files using plain C project in Qt Creator (command FILE)

    Qt Creator is a text editor, it has no influence on how your program behaves thus it cannot prevent you from using any language functionality in your program, especially at runtime. If you cannot create a file then most likely you don't have write permissions on the directory you are trying to create the file in.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2014
    Posts
    3
    Qt products
    Qt3

    Default Re: Creating files using plain C project in Qt Creator (command FILE)

    Thank you for the fast answer.

    How do I change the write permissions of the files to which I want Qt Creator to have access to (In Windows 7)?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Creating files using plain C project in Qt Creator (command FILE)

    You misunderstood: this is not about QtCreator at all. It is just an IDE, it creates the executable of your program but is not involved in its execution.

    You'll need to check that your program has access to whatever resources it needs from the operating system, e.g. files.
    Ask on a Windows forum if you are uncertain how it manages access rights.

    Cheers,
    _

  5. #5
    Join Date
    Oct 2014
    Posts
    3
    Qt products
    Qt3

    Default Re: Creating files using plain C project in Qt Creator (command FILE)

    Understood, thank you for the quick reply

Similar Threads

  1. Qt Creator Plain C++ Project won't run/debug...
    By jiapei100 in forum Qt Programming
    Replies: 9
    Last Post: 26th July 2012, 19:09
  2. Creating sis files for C project Using QtCreator
    By mathi in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 3rd April 2012, 12:51
  3. Replies: 0
    Last Post: 28th April 2011, 08:27
  4. Replies: 1
    Last Post: 4th December 2009, 00:34
  5. Replies: 3
    Last Post: 20th November 2009, 16:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.