|
-
Jan 24th, 2002, 11:27 AM
#1
Thread Starter
Addicted Member
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.
-
Jan 24th, 2002, 11:42 AM
#2
transcendental analytic
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++?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jan 24th, 2002, 01:43 PM
#3
there is do...while, which is valid C/C++ code. But there is no pure do.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 24th, 2002, 02:33 PM
#4
Thread Starter
Addicted Member
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?
-
Jan 25th, 2002, 03:57 AM
#5
You need to increment cnt every time you loop.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 25th, 2002, 10:49 AM
#6
Thread Starter
Addicted Member
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?
-
Jan 25th, 2002, 11:29 AM
#7
transcendental analytic
and i thought do was a vb thing hehe 
no, did you check if the file was opened correctly?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|