Well, once again, hello. I'm trying to figure out why when i use 2 cin.getlines after eachother it skips one of them and I cant use it. Take a look if you will:
void Join()
{
char* Username = new char[255];
char* Password = new char[255];
ofstream DataBase("DataBase.txt", ios::app);
cout << "Welcome New Member, Please Enter a New Username and Password:\n\n";
cout << "Username: ";
cin.getline(Username, 255);
DataBase << Username << "\n";
cout << "\nPassword: ";
cin.getline(Password, 255);
DataBase << Password << "\n\n";
cout << "\nSaved To Database!\n";
DataBase.close();
delete [] Username;
delete [] Password;
}
for some reason when I run the program and goto this function it will skip the first cin.getline and only let me type for the cin.getline that gets the Password. It's wierd because I ran a simple program similar to it, and it works fine:
#include <iostream>
#include <cstdlib>
#include <conio.h>
using namespace std;
int main (int argc, char* argv[]) {
char* string1 = new char[255];
char* string2 = new char[255];
cout << "String1: ";
cin.getline(string1, 255);
cout << "String2: ";
cin.getline(string2, 255);
cout << "\nString1 = " << string1 << endl;
cout << "String2 = " << string2 << endl;
delete[] string1;
delete[] string2;
getch();
return 0;
}
This code doesnt skip any cin.getline()'s for some reason, could it not work in the other one because of the file i/o? Maybe its making it act wierd? Any help is appreciated, thanks in advance.