here is my outline of code:
void apple()
{
cin >> price[i];
cout << price[i]; //give out correct value
}
void orange()
{
cin >> price2;
cout << price[i]; //mess value (like 65534 or 9460301)
}
int main()
{
string *fruit;
int *price;
fruit = new string[n]
price = new int[n]
for(int i=0,i<n){
cin >> fruit[i];
if (fruit[i]=="apple"){
apple();}
if (fruit[i]=="orange"){
orange();}
i++
}
}
just roughly outline,
i use pointer for apple but orange doesnt,
why i can get correct value from "cout <<" in apple,
but i get mess value from orange??