My Problem is Im trying to figure it out how can i used string of array that initialized to a text and how can i read out character by character, i know how to do this using string only and char but is there any way can i used string of array
string arr[2] = { "Tarik", "Neaj" };
cout << arr[1][3] << endl; // first [] accesses the entire string. Second [] accesses the individual characters within the string.
// this will print out the letter "j".
Sorry but I dont get your question. You dont have a string array in your code, what I showed you is a string array. Please elaborate on what you want and be specific. Also, as I said in my first post, please edit your post so we can help you the best way possible, it makes the code much more pleasant to read.
To get each individual characters from the "parpahpgragph" You just do storyLine[index] like you've done in your code. What exactly are you asking?
sorry i will try to explain again, what i want is how to count the number of 'a','p','h','g' and 'r' out from this "parpahpgragph" in using STRING ARRAY.
i know how to count individual character in using string only (not string array) and char array but need help on how can i use string array to count character by character.
what modification can i do to change this below code using string array that can count each individual character in "parpahpgragph";
You're not explaining things in the best way, but I might have gotten what you want, although it makes no sense.
Do you mean storing that paragraph in a string array? hmm okay, kinda makes no sense but, in that case you would need nested loops. You create a string array like I showed you in my example, then you use a nested loop.
1 2 3 4 5 6 7 8 9
string arr[2] = { "Tarik", "Neaj" };
for(int i = 0; i < 2; i++)
{
for(int j = 0; i < arr[i].lenght(); j++}
{
// do your stuff here
}
}
But why do you need a string array? A string arrays job is to hold multiple strings. You only have one string, the array is completely useless at that point. In any case, if you want to create an array of only one string, as weird as that is, you can just do it like this
Thank you very much your time and help, this is what i want, for your information why i want to use this it is the requirement of my assignment to use string array to store the story and count vowel out of it