Thursday, July 9, 2009

C programming?

Help with making a program in C to require a password to open a folder/file. The compiler that i use is made by bloodshed software.

C programming?
#include %26lt;stdio.h%26gt;





int main() {


char fileName[30];


char password[30];


char mypass[30] = 'KROMPED';





printf("What is the file name?\n");


scanf("%s", fileName);





printf("Password: ");


scanf("%s", password);





if (strcmp (password,mypass) != 0) {





FILE *fp;


if ((fp = fopen(fileName,"r")) == NULL) {


printf("Unable to open file");


return 0;


}





} else {


printf("You supplied the wrong password!");


}





return 0;


}


No comments:

Post a Comment