Letter and number

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.

1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
void main(void)
{
char username;
char password;
printf("Enter Username:");
scanf("%c", &username);
if (userid == jane1234)
..........
.........
}


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".
Do you want string?
1
2
3
4
5
6
7
8
9
10
11
12
13
#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";
}
Erm is there any variable and placeholder for stdio.h that include both letter and number. Sorry for the trouble.
Yes. c-string. %s
http://en.cppreference.com/w/cpp/io/c/fscanf
1
2
3
4
5
6
7
8
9
10
11
12
13
#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.
Char can hold charachters (both, numbers and letters). Like Minipa said string can do that too.
Topic archived. No new replies allowed.