this is what i have so far, i just need to know how to pass my cin >> "input" into my function.
Code:
5
6 #include <iostream>
7 #include <algorithm>
8 #include <string>
9 using namespace std;
10
11 void sortArray(int [], int);
12 void showArray(int [], int);
13
14 int main()
15 {
16
17 string name;
18 string name1;
19 string nameC;
20 int i;
21 string character;
22
23 // Ask user to enter a keyword
24 cout << "Enter a keyword without spaces: ";
25 cin >> name;
26 nameC=name;
27 name1=name;
28
29 // Displays the keyword in reverse order
30 reverse(name.begin(),name.end());
31 cout << name << endl;
32
33 // Displays keyword in Uppercase letters
34 for (i=0; name1[i] ; i++) name1 [i]=toupper(name1[i]);
35 cout << name1 << endl;
36
37 // Asks the user for what character do they want to look for
38 size_t found;
39 string str2;
40 cout << "What character are we looking for? ";
41 cin >> str2;
42
43 // Find the first character in the keyword
44 found=nameC.find(str2);
45 if (found!=string::npos)
46 cout << "First position found at: " << int(found) << endl;
47
48 // Find the last character in the keyword
49 string str = nameC;
50 string key = str2;
51 found=str.rfind(key);
52 if (found!=string::npos)
53 cout << "Last position found at: " << int(found) << endl;
54 else
55 cout << "Nothing is found";
56
57 // Sort the characters in order
58 char nameC[30] = nameC;
59 sortArray(values,6)
60
61 // Display the characters in order
62 showArray(values,6)
63
64 return 0;
65 }
66
67
68 void sortArray(int array[],int size)
69 {
70 bool swap;
71 int temp;
72
73 do
74 {
75 swap = false;
76 for (int count = 0; count < (size - 1); count++)
77 {
78 if (array[count] > array[count + 1])
79 {
80 temp = array[count + 1];
81 array[count] = array[count + 1];
82 array[count + 1] = temp;
83 swap = true;
84 }
85 }
86 } while (swap);
87 }
88
89 void showArray(int array[], int size)
90 {
91 for (int count = 0; count < size; count++)
92 cout << array[count] << " ";
93 cout << endl;
94 }