#include <iostream>
#include <cstring>
usingnamespace std;
int main()
{
char name[50];
char username[50];
cout<<"Please set your username: ";
cin.getline(username,50);
cout<<"Please enter your username: ";
cin.getline(name,50);
if(name == username){
cout<<"correct";
} else {
cout<<"incorrect";
}
}
and when i run and set a username and then enter the exact same it says it is incorrect, any help would be nice as I only started C++ like 3-4 days ago.
It will allow you to compare the two names as you do now, using operator ==.
Right now, using char[] what you are actually comparing is the base address of 2 char arrays, which will not be the same. You will understand this better once you learn about arrays and pointers.
char name[50] and char username[50] are arrays. Arrays have no the comparision operator. To compare two character arrays you should use standard C function strcmp declared in header <cstring>. For example