need help with functions

what im trying to do is have the person enter in a word and only display 5 of the letters of the word vertically with the usage of two functions, but im not getting it x_x, this is what i have so far:


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 getword(int a[]) {
    char input[5];
    cout << "Enter your name ";
    cin >> input;

}

int vertical(int b[]){
    for(int q=0;q<=4;q++)
        cout << b[q] << endl;

}


int main (){
    int a[]={};
    vertical(getword(a));
    return 0;
}


Line 20 is not legal C++, you must supply a size when you declare the array.

Passing what should be an int array to a function called getword seems a little suspect. Are your words normally made up of numbers?

In getword, input is a local buffer that ceases existing when the function ends. You don't even use the array you passed in.

Once again in vertical you're taking an array of type int, which is suspect.

Not that in:
vertical(getword(a));
getword returns a single int (except of course, you don't actually return anything from the function) and vertical expects an array, not a single int.

You also fail to return a value from vertical.
Topic archived. No new replies allowed.