| | |
PLEASE help with project - compile error
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2005
Posts: 17
Reputation:
Solved Threads: 0
C++ Syntax (Toggle Plain Text)
//project.cpp //compile error-price undeclared (first use this function) #include <iostream> //don't I have it declared in the float line?? #include <fstream.h> #include <stdlib.h> using namespace std; int main() //PROBLEM: Create an input file of recently shipped music CD's. The file should consist of // the name of the album, quantity shipped and price. Since we do not know how many CD's //have been shipped, keep reading the file until all CD's have been read in. Keep track of // both the number of different CDs as well as the total number of CDs shipped. //Your program should determine the value of each CD shipped (quantity * price). //Create an array to hold this value and print out all values in the array. { float CD[5]; int num; float qty=0, val=0; price=0; ifstream incd; ofstream outcd; incd.open("incd.txt"); outcd.open("outcd.txt"); if (incd.fail()) { cout<<"Output file doesn't exist!"; exit(1); } while (!incd.eof()) { incd>>CD[num]; //how does it read in qty & price and distinguish them?? for (num=0; num<5; num++) { incd>>CD[num]; qty = CD[num] + qty; val = qty * price; } outcd<<"The value of this CD is: "<<val<<endl; val = 0; qty = 0; price = 0; } num = incd.eof (); //same as while statement??? system("PAUSE"); incd.close(); return 0; }
>don't I have it declared in the float line??
No. If you had preceded it with a comma instead of a semicolon then yes:
No. If you had preceded it with a comma instead of a semicolon then yes:
float qty=0, val=0; price=0; New members chased away this month: 4
![]() |
Similar Threads
- visual c++ strange compile error... (C++)
- Dev-C++ - [Build Error] [main.o] Error 1 (C++)
- compile error (C++)
- C++ Compile Error's (C++)
- compile error (C)
Other Threads in the C++ Forum
- Previous Thread: Help. This is a strange problem
- Next Thread: Winsock Send File To Client Help
Views: 1476 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






