I made this code that you type in your name and it replies back. I type in my name and it works, then I have to type in my last name and when I do and hit enter it closes. Can anyone fix this? Here is the code. This is a DOS program. Thanks!
Code:#include <iostream.h> #include <string.h> int main() { char name[50]; char lastname[50]; cout<<"Enter your Name: "; cin.getline(name, 50, '\n'); if(!strcmpi("Joey", name)) { cout<<"Ha thats my name also."<<endl; } else { cout<<"Nope sorry thats not my name."; } cout<<"This is your name in uppercase..."<<endl; strupr(name); cout<<name<<endl; cout<<"And this is your name in lower case..."<<endl; strlwr(name); cout<<name<<endl; cout<<"Your name is "<<strlen(name)<<" letters long"<<endl; cout<<"Enter your lastname:"; cin.getline(lastname, 50, '\n'); strcat(name, " "); strcat(name, lastname); cout<<"Your full name is "<<name; return 0; }



LinkBack URL
About LinkBacks


