1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

File address

Discussion in 'Mac Programming' started by brcondor, Feb 12, 2012.

  1. macrumors newbie

    #1
    Hi all.
    I'm new to this forum.
    I'm going slightly mad for a little problem.
    I'm programming with Xcode using C language. I need to open a file and then to read it. I use fopen to open and fread to copy the informations inside this file.
    The problem is with fopen: how can I find the correct address for my file? I mean, i tried to just copy the address starting from /Users/name_users/fullpath/myfile.jpg but the pointer point to Null(it means, nothing happens).
    I tried to check if the address is correct from the command line but the answer is my folder doesn't exist: "iMac-di-andrea:~ andreacondorelli$ /Users/andreacondorelli/prova C/Prova/Prova/compressione/Compressione/Compressione
    -bash: /Users/andreacondorelli/prova: No such file or directory
    iMac-di-andrea:~ andreacondorelli$ /"

    If I try to open a file from desktop, i read "/Users/andreacondorelli/documents/test.jpg
    -bash: /Users/andreacondorelli/documents/test.jpg: Permission denied"

    Maybe the problem is with the permission.
    The C code is
    FILE *fp1;
    char nome[100];
    [...code here ...]
    fp1=fopen(nome,"rb");
     
  2. macrumors G5

    gnasher729

    #2
    There's a tiny little bit missing in the C code. I wonder why you didn't post it. Is it because you are absolutely sure that that part of the code is bug free? That's usually where you find the bugs.
     

Share This Page