I tried to store the numbers into 2d array while at the same time store the food names into 1d array. But I can't get it work. Can somebody tell me how to edit my code in order to get it work?
is hardly a helpful statement of your problem. Is it failing to compile? Crashing? Some other error? The more you tell us about the problem, the more we can help you.
Your code should test that the file has actually successfully opened. If it hasn't opened, then that would explain a problem at runtime.
Also, you need to revisit the logic of your loop, and think more rigorously about it. At line 21, when j is 6, that means that you've already read the final column, into numbers[i][6]. The subsequent input on line 23 is going to come from the next line. I don't think that's what you want.
I am not so sure how to "separate" the int with the string of the txt file.
I am able to do the 2d array of the int numbers. However, I can't make a separate 1d array that store the names of the foods.
I thought i can use j as counters to store the values into array.
Yes. That's not what I'm asking. It would be nice if you would read what I actually wrote.
Look at line 17. Look at the range of values j will take during the loop.
Look at line 19. Look at what values j will have when you use it to access the elements of your array. What value will j have on the first iteration of the loop? What column will it be looking at on the first iteration of the loop?