i m trying to create a project on username and password validation but while executing it accepts even wrong username and password stored in the file
(i m using turbo c++ and i m a beginner too)
It's not exactly a solution to your problem, but one thing that will help you, and the people you are asking for help, to understand your code is to use indenting. There are a variety of indenting schemes out there, but here's an example of how your code might look:
Now having taken a closer look at your code I notice that at least one thing you should do is initialize found to 0. Sometimes you will find that your data is zeroed for you, but you should never rely on this.
Also be wary of using sizeof(pass). This may not be giving 5 as you expect. It may be returning the size of pointers on your system. A simple test like cout<<sizeof(pass); should tell you.
I'm also noticing that strcmp is supposed to take c-strings, which are arrays of chars ending in 0 (note this is not the char '0'). Pass and pass2 do not have 0 at the end. However I would not expect this to result in a false positive.
I would suggest putting a cout statement before your while loop to double check the value of found and another one inside the if block to see if your strcmp is passing. Perhaps the one inside the if block could print out name2, uname, pass2 and pass to see in what conditions it's setting found to 1;
The password strings, pass and pass2 are't large enough.
You're probably not reading the password correctly as far as I can tell, and you're definitely not comparing pass and pass2 correctly. Have you tried running this in Turbo Debugger to see what's going on?