What’s up Gaza welcome to the thirty-eight tutorial of programming and C++ using Xcode in this tutorial is all about iterating with a returned pointer in the previous tutorial looked at pointer arguments to multiple dimension arrays whereas in this tutorial we will be able to have access to the calendar and then it’ll say week one to five pick a.

Week and then pick a date and then you’ll print out all the numbers from that day on so without further you left saw the video okay so.

We already have the calendar here so we can get rid of that and view on the screen and so we also need right on top int star so install and get date int week and in day so I’ll say cancel this and say W K equals to week and then dy equals put put on a new line if I could I put both on a new line in case it causes any confusion dy equals the day.

So the next time we have starting in calendar we have all that kind of they’re available for us it gets closed off here that we could go.
To a new line and say return return the calendar or we need an.

Ampersand there ampersand shift and seven gives you the.

Ampersand and then week square brackets week minus one and then square brackets again day minus one so that’s done we can then move on to the actual main function itself so if we close this off close it off that’s okay int main int week and they declare that close that off have a dowhile statement so do STD CLUT the week is 1 to 5 as you can see on top so we have 1 2 3 4 5.

5 weeks close that off and day is 1 to 7 because there are 7 days in a week so 1 – 1 – 7 not – close out after the semicolon and now the user inputs of STD cin w k WD close that off and then while the condition is week 1 less than.

A week less than 1 or week is greater than 6 or the day is greater than or less than 1 sorry and day is greater than 7 ok and so we.
Can eliminate that close out of the semicolon and in the statement.

We can say int star date equals so if I just copy all of this just copy that paste out here we could have just taken.

Naturally no so we can say the week on the day dy close that off with a semicolon – and then get rid of that and say while so now we went to the wire statement the condition will be star date.

Not equals to minus 1 eliminate that 2 and in the statement we can say STD cou T star date increment close that off that a new.

Space closeout of T okay so that needs to be closed off because it’s given an error this also needs to be deleted because we.

Don’t need that um we can de D Y so if I get rid of that dy okay so we are still getting an error for some reason use of undeclared identified dy I just get rid of that that should now fully function so we have a program that.

Iterates with a return pointer where it says int get date into week and.

In day a function that returns an address where it says STD cin week and a right at the top here prompt for and read subscripts so we want you to type in something into the terminal and where it says int start date get day weekend day call the function gates return the dress into a pointer and right at the end razor STD started increment use the pointer to iterate the array.

So we can run this because we have explained everything so we have week one to five and day one to seven so we can say if i just go back and did this again make it look.

With a colon and with the space then you press on because i just press space or so that acts as a character okay so we.

Qui will say week two and then you will say five okay it’s giving us an error so if i build this against a week two and six it’s giving us another error build that again to 626 week one to five.

I’ll just say one three we are getting all these errors for some reason let’s go back into the code and see what’s happening everything’s needs to be running correctly there you go after all those errors we finally managed to get something so if I was to.

Do this again run this program and say one two there you go run it again if I need three so week three and day four let me get all the numbers from 18 to 31 okay that’s it for this tutorial see you guys in the next video thanks for now.

Programming In C++ / Xcode || Tutorial 38 – Iterating With A Returned Pointer

Tagged on:                                                                                                                 
Alex Formenton Authentic Jersey