C programming
#5

Well.. lets make it step by step:

Quote:
Originally Posted by OrMisicL
Посмотреть сообщение
just one thing, why is that
pawn Код:
else
        {
            // Close file from reading.
            fclose(team_file);
            // ....
Why do u close the file when it fails to open ?
When it fails to open, i'm closing file handler to open it again for writing binary, because earlier I used it for read binary, to let me check if its created or not.

pawn Код:
// Open each file for reading binary.
        team_file = fopen(file_path, "rb");
             
        // If file exists in the given location.
        if(team_file)
        {
            count += 1;
            printf("\nFile is already created there!\nPress any key to continue. . .");
            getch();
        }
       
        else
        {
            // Close file from reading.
            fclose(team_file);
But maybe, there's more efficient way, if so, could you tell me please? Because I noticed that C uses standard file handling, but I stopped using it a while ago (I'm more familar with y_ini, which is a little bit different, but lets don't complain PAWN with C)

Quote:
Originally Posted by OrMisicL
Посмотреть сообщение
also, this is not a bug but, why the function return type is integer ? the func always returns 0 so u could just use "void" as a type and remove the return, but as i said its not a big deal, just to point it out
Tutor told me to use integer to return 0 always, because It's gonna mean:
Quote:
Originally Posted by Tutor
0 run time errors
And in other point, I can use return 1 if I need. That's what he said.
Reply


Messages In This Thread
C programming - by Riddick94 - 26.04.2013, 09:10
Re: C programming - by Fredrick - 26.04.2013, 09:13
Re: C programming - by Riddick94 - 26.04.2013, 10:28
Re: C programming - by OrMisicL - 26.04.2013, 11:15
Re: C programming - by Riddick94 - 26.04.2013, 11:26
Re: C programming - by OrMisicL - 26.04.2013, 11:32
Re: C programming - by Riddick94 - 26.04.2013, 12:01
Re: C programming - by playbox12 - 26.04.2013, 15:30

Forum Jump:


Users browsing this thread: 1 Guest(s)