Noob here. Ok so what I'm suppose to do is take short sentences from the user and output the reverse order of the user input to the user. IE:
I like blue
I hate red
Hello
a string array has index numbers right? well just make a cout array function and have another function that calls out the index in any order you choose, im gona have a pop at that now myself for fun, if its got to be dynamic, use vectors :)
youve over complicated it,your using a reference to the address of the array that is input and that [length] is going to increase in size, you want it to be the same length as the word you want and start at the right point and end at the right point...dude...vectors, less lines less overhead and more readible
"The Problem
In this assignment you will allow the user to type in a number of short, one line sentences. Each sentence is added to a buffer of 500 characters. Be sure that each sentence in the buffer is null terminated. As each sentence is added to this buffer, store a pointer to the sentence in an array of char pointers. When the user enters a zero, stop getting input from the user and display the sentences in the buffer in reverse order. Note, the sentences are in reverse order, not the words in the sentences. For example, if the user typed
I like the color red.
Blue is also a pretty color,
But I don't like orange.
0
your program would display
But I don't like orange.
Blue is also a pretty color.
I like the color red."
I think your problem is on line 29. You concatenate the strings before putting it into the array. If you wanted to do that you would need to increase inputPtr by length, but you don't have length (it is still 0), so it would be much easier to do this:
Try deleting line 29, and change line 30 to:
input[count++] = *temp;
I haven't tested that, just going on the idea of:
1 2 3
//get input
//assign to array
//print array in reverse
You can do simple debugging by placing extra cout statements to see what the value of different variables are at different points. Otherwise learn to use the debugger program in your IDE, which is easier in the long run. You can have a watch list of variables, see how they change as you step through the code 1 line at a time. See where they go wrong and deduce the problem.
> temp is the input, and we need to assign it to the array. I should have used temp not *temp.
They are not `std::string', you can't assign like that.
`strcpy' would be wrong too.