SH4D3H
New Member
... The Untrustable One ...
Posts: 3
|
Post by SH4D3H on May 18, 2004 7:31:45 GMT -5
I started C++ again after some time, and Im no pro or anything, but i dont know what im doing wrong here br] const int SIZE = 100; My compiler stops and gives an error the should be on this line. Whats wrong with it?
|
|
SH4D3H
New Member
... The Untrustable One ...
Posts: 3
|
Post by SH4D3H on May 18, 2004 7:36:17 GMT -5
I made a simple program to do inventory thats where the line is from. Though it gives more errors than only the const Here's the complete code (and yes i shud use files to save to ) #include <iostream> #include <cctype> #include <cstring> #include <cstdlib> using namespace std;
const int SIZE = 100;
struct inv_type { char item[40]; double cost; double retail; int on_hand; int lead_time; } invtry[SIZE];
void enter(), init_list(), display(); void update(), intput(int i); int menu();
int main(int argc, char *argv[]) { char choice; init_list(); for(;;) { choice = menu(); switch(choice) { case 'e': enter(); break; case 'd': display(); break; case 'u': update(); break; case 'q': return 0; } } }
void init_list() { int t; for(t=0; t<SIZE; t++) *invtry[t].item = '\0'; }
int menu() { char ch; cout << '\n'; do { cout << "(E)nter\n"; cout << "[img]http://xtcomputing.com/xtboard/beer.gif[/img]isplay\n"; cout << "(U)pdate\n"; cout << "(Q)uit\n\n"; cout << "Choose one : "; cin >> ch; } while(!strchr("eduq", tolower(ch))); return tolower(ch); }
void enter() { int i; for(i=1; i<SIZE; i++) if(!*invtry[i].item) break; if(i==SIZE) { cout << "List full.\n"; return; } input(i); }
void input(int i) { char str[80]; cout << "Item: "; cin >> invtry[i].item; cout << "Cost: "; cin >> invtry[i].cost; cout << "Retail price: "; cin >> invtry[i].retail; cout << "On hand: "; cin >> invtry[i].on_hand; cout << "Lead time to resupply (in days): "; cin >> invtry[i].lead_time; }
void update() { int i; char name[80]; cout << "Enter item: "; cin >> name; for(i=0; i<SIZE; i++) if(!strcmp(name, invtry[i].item)) break; if(i==SIZE) { cout << "Item not found.\n"; return; } cout << "Enter new information.\n"; input(i); }
void display() { int t; for(t=0; t<SIZE; t++) { if(*invtry[t].item) { cout << invtry[t].item << '\n'; cout << "Cost: $" << invtry[t].cost; cout << "\nRetail: $"; cout << invtry[t].retail << '\n'; cout << "On hand: " << invtry[t].on_hand; cout << "\nResupply time: "; cout << invtry[t].lead_time << " days\n\n"; } } }
|
|
SH4D3H
New Member
... The Untrustable One ...
Posts: 3
|
Post by SH4D3H on May 18, 2004 10:03:15 GMT -5
Nm it works now
|
|