function to output specific no. of chars of string

i'm trying to use a function to define a string and then calling its value in the main function. the problem is that i have to output only a specific number of elements of the string, not the whole string. i've reached this far right now, someone kindly guide me further :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

using namespace std;

void letters (string a)

{

cout << a << endl;

}

int main()

{

string one;

cin >> one;
letters (one);

return 0;

}
You can use the substr() function to use part of the string.
Here is it's documentation:
http://www.cplusplus.com/reference/string/string/substr.html
Topic archived. No new replies allowed.