If you mean by standard input (i.e. cin), then you simply use the name of the array and the subscript (inside the array operator, []) you want to put the value in. So something like:
items[0] = "Banana";
would put "Banana" in the 0th element of the array.
A more efficient method would be to use a for loop that iterates from 0 to less than the number of elements in the array. See the following program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
usingnamespace std;
int main()
{
string items[] = {"item1","item2","item3"};
for(int n=0; n<3; n++) // For loop goes from 0 to 2, as there is no 3rd element
cin >> items[i]; // in each iteration, let user cin the nth element
// we can print out the array in the exact same way to see that it worked
for(int k=0; k<3; k++)
cout << items[k] << " ";
}
No, I mean that items 1-3 will have a value of a number like 1 or 5, is there even a way to code it like that or is it even possible? Or the only way the items would have a value is to code
Well, thats not really the syntax or the answer I'm looking for ..
From this end the following approach is mutually more beneficial than a 20 questions exercise.
I suggest you run it as a program, show us the program including any output and error messages (with line numbers) that you get. Then tell us why your output isn't as you expect.
If you've already specified items[0] as string "item1" 500 will not be the value in the items array, in fact you'll have a type error on your hands.
But please be a good chap and do what I suggested above. :)