I'm wondering if this is a good or bad way of using pointers and new. I don't want to store more than I need, so therefore I make a buffer of 50 and the user write their username, and I use strlen to count it and store the length + 1. Do I have to delete username afterwards? Should I do this different?
Without using string.
void Accounts::newUser()
{
    char buffer[50]; char *username;
    cout << "username: ";  cin.getline(buffer, 50);
    username = new char[strlen(buffer) + 1]; strcpy(username, buffer);
    // User(char *username) <- parameter
    accountList->add(new User(username));
}
 
     
    