Those who are helping me please note that if you are editing the program, keep the complete program as an answer...as I am just a beginner student wont be knowing much....also note that please don't make it too complicated my teacher will scold me...[only 12 standard content].some variables are extra which i used for the rest of the program
Thank You in Advance
Christy
Firstly, your code isn't laid out very well. Were you writing this in an IDE, or using a text editor? You should indent, and use spaces between the "cout" and the "<<", and then between the "<<" and the string, etc. I recommend using a text editor that does it automatically.
As for why it isn't working, at a glance you're using cout, but you included <fstream> instead of <iostream>, and you didn't set it to use the std namespace. Also, your main function should return an integer. You also have an extra '(' at the start of your if statement, and you're missing a curly brace at the end of your code. The one directly under clrscr() ends the else statement, and the one below that closes the while loop, but there's nothing after that to end the main function. Also, if you change the password input loop to this, the user will be able to delete characters from the password as they type, if they make a mistake:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
while( (i=getch())!= 13)
{
if (i == 8)
{
if (a > 0)
{
cout << "\b \b";
cin.sync();
a--;
}
}
else
{
password[a] = i;
cout << '*';
a++;
}
}
I will give you the suggestions for the program, not the answer itself (first letting you figure it out). I made it with relative ease (and I am a beginner too).
1. Create a for loop (Stop and go read about them if you don't know about them).
2.use the getch() function to read individual characters to each member of the Username array (as Username[i] = getch();) with the condition for the loop being the number of elements in the array.
3.Put an condition that if (Username[i] == 13) break;. 13 is the ASCII code for Enter. This will stop the loop if the user presses Enter.
4. Create another loop inside the above loop to print the stars as many times as you have looped originally.
5.Use the clrscr() function to clear the screen and continue.
6.Close the loop.
From the above code I can figure out that you can do the checking part yourself!