Opening files using fopen only if user enters correct password
Don't repeat yourself. This block of code appears twice. It would be better to extract it to a separate function and reuse it:


        if((fp=fopen("text","r")) != NULL)
        {
                while((c=getc(fp)) != EOF)
                {
                        putchar(c);
                }
                fclose(fp);                     //close the file once done
        }
        else
        {
                perror("Error:");
                return(-1);
        }



Btw, is there a reason to read and print the file contents character by character? It would be more efficient to do it buffer by buffer.

Also, the comment is pointless, that line is self-explanatory. 



In this code:


if(strcmp(password,input)==0)
{
        // ...
}
else if(strcmp(password,input) != 0)



The else if condition can be replaced with a simple else. That's less typing, and again, don't repeat yourself!