confusion with the void function

Hey. It's me again, the worlds worst programmer. Anyways, I never was able to complete the diamond shape because I still don't understand how it works, so uh maybe somebody out there can offer some pointers on what I'm doing wrong with this one.

I'm using the void function in order to make a header and closer with the '*' character. Anyways, here is the code. Once again, any help is much appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <string>


using namespace std;


void display();
int main()

{



{





    string name, saddress, caddress;

    cout<<"Enter full name: "<<endl;
    getline(cin, name);
    cout<<"Enter street address: "<<endl;
    getline(cin,saddress);
    cout<<"Enter city address: "<<endl;
    getline(cin,caddress);

    display();


    cout<<name<<endl;
    cout<<saddress<<endl;
    cout<<caddress<<endl;

    display();
    return 0;


}



        void display()






    for(int i=1; i<=30; i++)

    {
        cout <<"*"<<endl;
    }








}




There are supposed to be two separate functions here, but somehow one has ended up being defined inside the other, which isn't permitted.

The open brace { at line 15 doesn't belong there, delete it.
And then insert the missing open brace at line 46.

A bit of tidying up to get rid of some of the blank lines and an adjustment to the indentation (remove the indentation of line 45 ) will aid legibility.

Topic archived. No new replies allowed.