I've been working on a program where I'm taking data from a text file and putting it into a 2d array called str.
The issue is that later on I want to output individual values from str based on two variables, but haven't found success. I can't find a way to make printf work, and when I use a dummy int value I get the message "cannot convert 'std::string' to 'int' in assignment. I feel like there should be an easy way round this but has been a while since I've used c++
Thanks, that's very helpful. However I need to manipulate some of the data into an equilateral triangle, based on what I did when using random integers instead of importing from a textfile I thus to change the print section to:
1 2 3 4 5 6 7 8 9 10 11
for (int i = 0; i < 4; i++)
for (int j = 0; j <= i; j++)
printf("%d\t", str[i][j]) ;
However this has the issue that j isn't defined, and I haven't been able to solve using dummy variable to take the value of j.