No.
That's for C input and output like printf and scanf. If you are definitely doing this in C++ you want to be using cout and cin for output and input, and use: #include<iostream>
So you don't want to write this in C++ then?
if you want to use C I suggest googling "C input and output". If you want to use C++, I'd stick with my first suggestion and go through some of the tutorials on this site.
People on this site can help you a bit more if you actually post some of your code.
printf("Please enter your username.\n");
scanf("%s", UserName);
printf("Please enter your password: \n");
scanf("%s", PassWord);
if (UserName == "iluvcake")
{
if (PassWord == "Chocolate")
{
printf("Welcome!\n");
}
}
else
{
printf("The user name or password you entered is invalid.\n");
}
i dont know how to create a loop in this. so if the person enters a wrong user name and password.. it should say invalid username and password and starts from the start again
while( !password(input) ){
std::cerr << "Invalid password. Enter it again.\n";
//...
}
> UserName == "iluvcake"
to compare c-strings you need to use the strcmp() function
(pay attention, as your code will compile but it compares the pointers, not the content)