How to create C++ program to display name and address

Hello,

Hope every-buddy is fine, and thanks in advance. I am new to C++ -- I want to write a simple C++ program which takes input from user and displays it. The program I want is take name and address in input and display it. Below is the code written by me, can someone point out the mistake I have done??

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 #include <iostream>

using namespace std;

int main()

{
    int name, address;
    
    name = " ";
    address = " ";
    
    cout << "Enter you name" << endl;
    cin >> name;
    cout << "Enter your address" << endl;
    cin >> address;
    cout << name << address;  
    
    system ("PAUSE");
    
    return 0;  
    
}


I have solved up mentioned problem but got another problem:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <string.h>

using namespace std;

int main()

{
    
    char name[50]; 
    char address[200];
    cout << "Enter you name" << endl;
    cin >> name;
    cout << "Enter your address" << endl;
    cin >> address;
    cout << name << address << endl ;  
    
    system ("PAUSE");
    
    return 0;  
    
}


It shows the name but don't show full address.
Last edited on
Line 2: #include <string>
Line 10: std::string name;
Line 11: std::string address;

Line 18: Remove the abomination.
Last edited on
Topic archived. No new replies allowed.