hello, i keep getting this error in my c++ program: incompatible types of assignment of ' const char[2]' to 'char[20]'
what does this mean???
hello, i keep getting this error in my c++ program: incompatible types of assignment of ' const char[2]' to 'char[20]'
what does this mean???
I'm pretty sure what the problem is, just post your code so we can show you how to fix it...
This is the code, its for a school assignment
Code:#include <iostream.h> #include<string> int main() { char manager[20]; char product1 [20]; float price1; char product2 [20]; float price2; char product3 [20]; float price3; char product4 [20]; float price4; char product5 [20]; float price5; char date [20]; char storelocation [20]; char x; float Total; cout<<"Enter the location of the woolworths store"; cin>> storelocation; cout<<"Enter the date of purchases"; cin>> date; cout<<"Enter the store manager's name"; cin>> manager; cout<<"Enter the product and weight, if finished type '0' in"; cin>> product1; cout<<"Enter the price of the product"; cin>> price2; if (product1 = "x") cout<< "Thanks, press enter to receive a receipt"; else cout<<"Enter the product and weight, if finished type '0' in"; cin>> product2; cout<<"Enter the price of the product"; cin>> price2; if (product2 = "0") cout<< "Thanks, press enter to receive a receipt"; else cout<<"Enter the product and weight, if finished type '0' in"; cin>> product3; cout<<"Enter the price of the product"; cin>> price3; if (product3 = "0") cout<< "Thanks, press enter to receive a receipt"; else cout<<"Enter the product and weight, if finished type '0' in"; cin>> product4; cout<<"Enter the price of the product"; cin>> price4; if (product4 = "0") cout<< "Thanks, press enter to receive a receipt"; else cout<<"Enter the product and weight, if finished type '0' in"; cin>> product5; cout<<"Enter the price of the product"; cin>> price5; if (product5 = "0") cout<< "Thanks, press enter to receive a receipt"; Total = (price1 + price2 + price3 + price4 + price5) cout<<" PROUDLY AUSTRALIAN " cout<<" WOOLWORTHS " cout<<" ABN 88 000 014 675 " cout<<" The Fresh Food People " cout<<" Mona Vale Ph: 9997-4777 " cout<<" YOUR STORE MANAGER IS:" <<manager cout<<" $. " cout<<" ------- " cout<<" " <<product1 <<price1 cout<<" " if (product2 > "z") <<product2 <<price2 cout<<" " if (product3 > "z") <<product3 <<price3 cout<<" " if (product4 > "z") <<product4 <<price4 cout<<" " if (product5 > "z") <<product5 <<price5 cout<<" 5 TOTAL " <<Total cout<<" E.F.T " <<Total cout<"----------------------------------------------" }
// edit: you also forgot alot of ;'s towards the end of your codeCode:// lines like this are illegal if (product1 = "x") // use the strcmp function in strings.h to compare strings for equality like so... if (strcmp(product1, "x") == 0)
Last edited by face_master; 11-22-2002 at 12:32 AM.
thanks a lot for that face master, it seemed to do the trick!
however i still have one error which i cant solve (im a doofus)
it says: parse error before '<' on line 65 which is the cout<<" PROUDLY AUSTRALIAN " line.
can u plz tell me whats wrong?
your code was pretty crazy, but I made some fixes here and there but you might want fix it some more
Code:#include <iostream.h> #include<string> int main() { char manager[20]; char product1 [20]; float price1 = 0; char product2 [20]; float price2 = 0; char product3 [20]; float price3 = 0; char product4 [20]; float price4 = 0; char product5 [20]; float price5 = 0; char date [20]; char storelocation [20]; float Total; cout<<"Enter the location of the woolworths store"; cin>> storelocation; cout<<"Enter the date of purchases"; cin>> date; cout<<"Enter the store manager's name"; cin>> manager; cout<<"Enter the product and weight, if finished type '0' in"; cin>> product1; cout<<"Enter the price of the product"; cin>> price2; if (strcmp(product1, "x") == 0) cout<< "Thanks, press enter to receive a receipt"; else cout<<"Enter the product and weight, if finished type '0' in"; cin>> product2; cout<<"Enter the price of the product"; cin>> price2; if (strcmp(product2, "0") == 0) cout<< "Thanks, press enter to receive a receipt"; else cout<<"Enter the product and weight, if finished type '0' in"; cin>> product3; cout<<"Enter the price of the product"; cin>> price3; if (strcmp(product3, "0") == 0) cout<< "Thanks, press enter to receive a receipt"; else cout<<"Enter the product and weight, if finished type '0' in"; cin>> product4; cout<<"Enter the price of the product"; cin>> price4; if (strcmp(product4, "0") == 0) cout<< "Thanks, press enter to receive a receipt"; else cout<<"Enter the product and weight, if finished type '0' in"; cin>> product5; cout<<"Enter the price of the product"; cin>> price5; if (strcmp(product5, "0") == 0) cout<< "Thanks, press enter to receive a receipt"; Total = (price1 + price2 + price3 + price4 + price5); cout<<" PROUDLY AUSTRALIAN \n"; cout<<" WOOLWORTHS \n"; cout<<" ABN 88 000 014 675 \n"; cout<<" The Fresh Food People \n"; cout<<" Mona Vale Ph: 9997-4777 \n"; cout<<" YOUR STORE MANAGER IS:" <<manager << "\n"; cout<<" $. \n"; cout<<" ------- \n"; cout<<" \n"; cout<<product1; cout<<price1; cout<<" \n"; if (product2 > "z") { cout <<product2; cout <<price2; } cout<<" \n"; if (product3 > "z") { cout<<product3; cout<<price3; } cout<<" \n"; if (product4 > "z") { cout<<product4; cout<<price4; } cout<<" \n"; if (product5 > "z") { cout<<product5; cout<<price5; } cout<<" 5 TOTAL " <<Total; cout<<" E.F.T " <<Total; cout<<"----------------------------------------------"; return 0; }
Probably becuase of all of the missing ;'s or something...Originally posted by holoduke
thanks a lot for that face master, it seemed to do the trick!
however i still have one error which i cant solve (im a doofus)
it says: parse error before '<' on line 65 which is the cout<<" PROUDLY AUSTRALIAN " line.
can u plz tell me whats wrong?
Lol, I wok at a woolworths - it sucks. I do like no work so they dont like me. Only work some weekends, though so its ok. I'm 15 by the way
thank you so much! you are a 15 yr old genius!
im 15yrs old and i cant understand c++, but ive only been learning it for 2 weeks.
Woolies keeps rejecting my applications...
hey face master how do u make the code u wrote print the actual receipt? it doesnt seem to want to do that
>> Woolies keeps rejecting my applications...
Serious? Lol. It was easy for me. Somehow I got the job. I tried for a job @ hoyts couple weeks ago, but they knocked me back. I work on a checkout but thats becuase you do the least work
>> hey face master how do u make the code u wrote print the actual receipt? it doesnt seem to want to do that
Yeh thats pretty weird how it just stops. I'll have a go at it now...
Your program is really screwed. I need to go now but i'll try fixing it later
ok thanks
do u know how to fix it?
Hmm, take a look at the if's and else's
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.