Hi, I try everything to fix this with pointers and etc... But I dont know if is me that doesn't know used them or not... Whatever, I keep getting this message in terminal of linux "segmentation fail", if you could help me I would be grateful, here is the code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int store_more;
int store_months[2][3];
int total_sales,month_min,month_max;
int l,m;
for (int l = 0; l < 2; l++){
for (int m = 0; m < 3; m++){
cout<<"Enter the sales of the month "<<m<<" the store "<<l<<": ";
cin>>store_months[l][m];
cout<<endl;
}
}
store_more[l] += store_months[l][m];
if (store_more[0] > store_more[1]){
cout<<"Store 0 sell more"<<endl;
This code shouldn't even compile. You are using store_more as if it was an array but you have declared it as an int. Also note that l and m are two different variables than l and m inside the nested loops so they are not initialized when you use them later in the code.