From fcfb2db63b01f209fb2c8fdc500023241435377f Mon Sep 17 00:00:00 2001 From: zlg Date: Mon, 27 Feb 2017 01:20:38 -0800 Subject: Solve Exercise 7-9: isupper, time, and space --- ch7/7-09_isupper-time-space.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 ch7/7-09_isupper-time-space.c (limited to 'ch7') diff --git a/ch7/7-09_isupper-time-space.c b/ch7/7-09_isupper-time-space.c new file mode 100644 index 0000000..bc96551 --- /dev/null +++ b/ch7/7-09_isupper-time-space.c @@ -0,0 +1,32 @@ +#include +#include /* strchr */ + +/* The C Programming Language: 2nd Edition + * + * Exercise 7-9: Functions like `isupper` can be implemented to save space + * or to save time. Explore both possibilities. + * + * Notes: I'm not really sure what they're expecting here. Assuming standard + * ASCII, the only uppercase characters are A-Z, and they're all sequential. + * Both ways to check seem very lean on necessary resources; I'm unaware of + * other methods. + */ + +int isupper_small(int c) { + return (c >= 'A' && c <= 'Z'); +} + +int isupper_fast(int c) { + return (strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", c) != NULL); +} + +int main(int argc, char **argv) { + int c = 'S'; + /* The inline conditional makes things more "human-friendly". */ + printf("is '%c' uppercase? %c\n", c, isupper_fast(c) ? 'y' : 'n'); + c = 'f'; + printf("...what about '%c'? %c\n", c, isupper_small(c) ? 'y' : 'n'); + c = ':'; + printf("Does a colon have an uppercase variant? %c\n", isupper_small(c) ? 'y' : 'n'); + return 0; +} -- cgit v1.2.3-54-g00ecf '>log msg
path: root/src (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2025-07-27README.md: update to include mentions of *_date fieldszlg1-7/+26
2025-07-27Finish integrating support for p_date, et alzlg2-23/+59
* Tightened up update_game() to use explicit fields * 'unowned' and 'unbeatable' status now show as blank fields in list_game() output * Results are counted and a proper message is emitted instead of erroring when there are no results. * Support p_date, b_date, and c_date in the CLI
2025-01-24Add support for p_date, b_date, c_date to CLIzlg2-48/+136
The library and CLI tool both can handle the new schema v2 that includes these columns. Please use the schema migration script in the "scripts" directory to continue using VGStash. The list_games function has been completely re-worked to handle arbitrary tabular data. Raw mode has remained, but the width switch (-w) for default table view is no longer present. The first VIEW supporting these columns is also available in FILTERS: the backlog_age filter, which will show you the amount of time games with a purchase date value have been sitting in your collection unbeaten.
2025-01-24tox.ini: Update to Python 3.11 env by defaultzlg1-1/+1
2025-01-23schema1-to-2.py: Add shebang because I'm a doofuszlg1-0/+2
2023-09-22scripts: Add schema v1->v2 migration scriptzlg2-9/+85
This script adds three columns to the schema, supporting the "Purchased", "Beaten", and "Completed" note headers. They are now converted to a UNIX timestamp and stored in a separate column so queries made against that metadata are easier. The library itself still needs to support all the new columns.