my code malfunction if i add this part to it why?

Hi all i have this code that i wrote and if i include this particular part it just doesnt read the next cin anyone can help me?

int main()
{
//create user
char string1[100];
char string2[100];
char string3[100];
char str1[100];
char txt[5] = ".txt";
char checkuser[100];
char username[100];
char newusername[100];

ofstream myfile;
1 cout << "create your user name:\n";
2 cin >> newusername;
3 strcpy(string3,newusername);
4 strcpy(string1,txt);
5 strncat(string3,string1,100);
myfile.open (string3);
cout << "Enter Password\n";
cin.get(str1,100);
caesar(str1);
string i = str1;
myfile << i;
myfile.close();


//opening and reading file
fstream user;
cout << "please enter user name\n";
cin >> checkuser;
strcpy(string1,txt);
strcpy(string2,checkuser);
strncat(string2,string1,100);
user.open(string2);
user >> username;
revcaesar(username);
cout << username;
return 0;


}

Thanks in advance anyone that helps!! im beginner : )

edited the numbers that i mark out beside the code is giving the problem :(
Last edited on
hi,

Try a cin.ignore(1)
after your cin >> newusername to get rid of the linefeed in the cin buffer.

hope this helps
Shredded
Hi Shredded,

Thanks a bunch! it worked : )

Regards,
Desmond
Topic archived. No new replies allowed.