simple calculation of char?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
void viewWasteReport(){
	EXEC SQL BEGIN DECLARE SECTION;
	char wasteid[5],wastetype[31],month[11],wastequantity[13],wasteweight[11];
	//double wastequantity[13];
	//double wasteweight[11];
	EXEC SQL END DECLARE SECTION;
	fnConnectDB();
	int total=0;
	system("cls");
	cout<<"\n\t\t\t\t\t\t\t######################################################\n";
	cout<<"\n\t\t\t\t\t\t\t#                 VIEW WASTE REPORT                  #\n\n";
	cout<<"\t\t\t\t\t\t\t######################################################\n";
	cout<<"\n\tPlease enter : ";
	cout<<"\n\tWaste ID : ";
	input(wasteid);
	if (wasteid[0]==27)
		reportMenu();
	cin.clear();
	//cin.ignore(numeric_limits<streamsize>::max(),'\n');
	EXEC SQL SELECT * INTO :wasteid,:wastetype,:wastequantity,:wasteweight FROM waste WHERE wasteid = :wasteid;
	if(sqlca.sqlcode==0){
	system("cls");
	cout<<"\n\t\t\t\t\t\t\t######################################################\n";
	cout<<"\n\t\t\t\t\t\t\t#                VIEW WASTE REPORT                   #\n\n";
	cout<<"\t\t\t\t\t\t\t######################################################\n";
	cout<<"\n\tMonth Collected       : December\n\t";

	//double wastequantity, wasteweight;

	//cout<<"\n\tTotal Waste Collected : "<<wastequantity*wasteweight;
	cout<<"\n\tWaste Type            : "<<wastetype;
	cout<<"\n\tWaste Quantity        : "<<wastequantity;
	cout<<"\n\tWaste Weight (kg)     : "<<wasteweight;
	total++;
	cout<<"\n\t"<<total<<endl;
	cout<<"\n\t";
	system("pause");
	wasteMenu();
}
else
	{	cout<<"\n\tNo record found"<<"\n\t";
		system("pause");
		reportMenu();
	}
fnCloseDBConnection();
}


i want to obtain the the product of wastequantity*wasteweight, but i get error.

please, help needed. thanks
How do you multiply a vector with 13 elements in, by a vector with 11 elements in?

Forget the C++ code for now - mathematically, what is it that you actually want to do?
Last edited on
mathematically,
i want to calculate wastequantity X wasteweight per unit = total waste weight collected.
but when i change to same vector size [13],
i still got error

1>c:\users\documents\visual studio 2008\projects\staffmenu.cpp(516) : error C2296: '*' : illegal, left operand has type 'char [13]'
1>c:\users\documents\visual studio 2008\projects\staffmenu.cpp(516) : error C2297: '*' : illegal, right operand has type 'char [13]'
closed account (Dy7SLyTq)
its because you are taking sql codes and literally injecting them into your code. theres probably a function they are supposed to go in. c++ has no idea what sql is
so how the correct way i should do the coding?

im a serious noob in this c++ & sql stuff,
but need to show this project tomorrow.

please.
closed account (Dy7SLyTq)
i have never used sql and c++ (but i probably need to for my website). i just know that its not valid c++ to literally inject the commands. there is a function in the sql api that executes it for you
Topic archived. No new replies allowed.