LaunchCode-Education-Archived / cs50x-live

The generic template version of Launchcode's CS50x curriculum. Fork this to create a repo for a particular city.
Creative Commons Zero v1.0 Universal
2 stars 5 forks source link

exercise: previous #172

Closed stlou closed 8 years ago

stlou commented 8 years ago

What's the point of the validation in previous.c?

We have it print, "please provide me one integer" and then in a new line "usage: previous n", which just seems kind of weird. What's that second line saying?

Also a small typo, need an apostrophe in don't

jesseilev commented 8 years ago

the "usage" thing is new to people, explain it a little

jesseilev commented 8 years ago

@stlou The point of the validation is that you should never access an array at an index that is beyond the bounds of the array:

string input = argv[1];

You only want to do the above if you know for sure that argv actually does contain a value at index 1.

Should I add some explanation for this?

jesseilev commented 8 years ago

I added some //comments which should provide sufficient clarification of both things: