-
File Loop Help
do
{
inFile >> arrProNum[cnt] >> arrProDesc[cnt] >> arrProPrice[cnt] >> arrProTax[cnt];
total++;
}
This loop refuses to input from a file. Here is the text in the file:
00001 Bread 2.00 N
00002 Butter 2.35 T
00003 Soup 3.59 N
00004 Carrots 2.79 N
00005 Potatos 5.89 T
Anybody know why this does not loop these products into these parallel arrays?
Thanks much in advance.
-
do? you don't have do's in C++, only while() and for(;;) should your loop be infinite? shouldn't you have cnt++ instead of total++?
-
there is do...while, which is valid C/C++ code. But there is no pure do.
-
So...
That cnt is used later in the program, I need total for something else. Now, how can I fix my code, and yes, Do...while loops are valid in C++. Any reccomendations for my code, though?
-
You need to increment cnt every time you loop.
-
Stupid accidents...
do
{
inFile >> arrProNum[total] >> arrProDesc[total] >> arrProPrice[total] >> arrProTax[total];
total++;
}
while (inFile);
There's the new code, I found that before I got home and checked out the post again, but thanks, that's a big deal, lol. Does anybody know why it still doesn't input stuff right?
-
and i thought do was a vb thing hehe :p
no, did you check if the file was opened correctly?