Have a bit of an esoteric C programming scenario today, and because it is esoteric, and some or all of you may fall asleep, am also going to show you how to debug in Xcode … and only now just realized with the podcast of this tutorial that we went, on a Mac, control-command-Y a lot and should have, instead, shown you this in menu manipulation terms as Product->Debug->Continue … anyway, if you get into this, you’ll know what is going on.
Okay, so the C scenario in Xcode is a bit esoteric, as sometimes happens when you are answering “a brief” (a Yahoo Answers brief). The brief was not to use strcat in the making of a single string buffer from an array of zero-byte terminated char* strings in an array, with an added stipulation of a maximum string buffer length. Sounds simple, and it is if you use strcat and/or global strings, but my understanding of the brief would be that global variables will be frowned upon, as a lot of programmers will tell you. Mind you, personally, global strings are not a problem for me. Not using global strings and not using strcat, and making this work in a self-sufficient single function is quite interesting, and basically that is what we do here with this tutorial, via memory management using malloc & realloc.
So feel free to download the Xcode C programming source code here and rename it to main.cpp (or main.c … is pretty conservative in its construction … probably would work with Digital Mars C).
Hope you enjoy this tutorial showing you some cute Xcode debugging functionality.
If this was interesting you may be interested in this too.
8 Responses to Xcode Debug C Strings Program Tutorial