What is the variable that allow both letters and numbers inside? Here is an example of the code. It is just an example to give you guys an idea of what I am talking about.
Please help me as I am just a beginner in C++. I know char is not the correct variable and %c is not the correct place holder. But I do not know what is the correct variable and place holder that accept both letter and number such as this "jane1234".
#include <iostream> //There is no need for C io
#include <string>
int main() //void main() is illegal in both C and C++
{
std::string input;
std::cout << "Enter Username: ";
std::cin >> input;
if (input == "jane1234") {
std::cout << "Hey! I remember you.\n";
}
std::cout << "End of program\n";
}
#include <cstdio> //use cstdio in C++ instead of stdio.h
#include <cstring> //instead of string.h
int main() //void main() is illegal in both C and C++
{
printf("%s", "Enter Username: ");
char buffer[10];
scanf("%9s", buffer); //Cannot read more than 9 characters. Make sure your users know it
if(strcmp(buffer, "jane1234") == 0) { //Unwieldy C-style comparison
printf("%s", "Hey! I remember you.\n");
}
printf("%s", "End of program\n");
}
Enjoy manual memory management and overflow riscs.