So, I'm making a program that will let the user input his/her allowance for 30 days after which, they will input their accumulated expenses for that month. The program will then subtract the allowance from the expenses and display it. I am to use two dimensional arrays, pointers, structures and void functions.
Here's what I currently have:
#include<iostream>
#include<iomanip>
#include<string>
#include<cmath>
usingnamespace std;
struct variables{int expenses;
int allowance[1][30];
int sum;
int total;};
int main()
{
int *a, *e, p1, p2;
variables x = {0};
cout << "Please enter your daily allowance for this month: " << endl;
for(int week=0;week<1;week++)
{
cout << "Week " << week+1 << endl;
for (int day=0;day<30;day++)
{
cout << "Day " << day+1 << ": ";
cin >> x.allowance[week][day];
}
}
for(int week=0;week<1;week++)
{
cout << "Week " << week+1 << endl;
for (int day=0;day<30;day++)
{
cout << " " << x.allowance[week][day];
x.sum+=x.allowance[week][day];
}cout << " " << endl;
}cout << "Total allowance is: " << x.sum;
system("pause>0");
return 0;
}
I'm currently stuck on how will I use pointers and a void function. I want to use pointers and a void function on the last part of my program(input of expenses and subtraction of allowance from expenses) but I have no idea how to do it. Can anyone give me some tips on how I can do that?