Hello, I'm having trouble with my assignment. We're supposed to create a string type 2D Array of 4 columns and 3 rows. The user has to enter 12 names or words then it's supposed to display it back to the user in a spreadsheet table style.
string01 string02 string03
string04 string05 string06
string07 string08 string09
string10 string11 string12
I'm having trouble displaying the table back to the user. All I get is
"The 12 names/words you entered were: "
The problem you have defined the array in both your functions and when the functions end so the the variables defined in each function.
You need to define the array in "main" and pass it to the functions.
It is also helpful to post the full instructions given to you , so everyone will know what you have to do and what you can and can not use. Otherwise you will get answers that are beyond what you have learned. Or suggestions that go against what you have learned.
In int main() if you are not going to use "argc" and "argv" you do not need to put them in. It is a waste of storage space if you do not need them.
Give me a few minutes and I will give you an example.
Where possible, favour pre-inc rather than post-inc.
Just saying -- it really doesn't matter for ints as far as performance is concerned. In fact, the assembly will be exactly the same if you start index at 1 but post-increment. But in this case with the index variable, I'd agree it's slightly cleaner to use pre-increment. https://godbolt.org/z/4ThfPYW85 https://godbolt.org/z/bM1Gb7fqb