L
Laurel Shimer
Working to develop comfort with the language,I have been typing up
and running the code examples, and thinking through each line in each
example to make sure I know what each command is doing. Then I try to
make up my own very simple examples in the style of the ones in the
book.
(actually I have 3 books I go between, trying things out, and figuring
out my personal study plan. I tend to work within a particular book
for a couple of weeks. I return back once another author has gotten
me over a stumbling block - self-study ain't easy)
I'm currently working in the most basic of the 3 books ("Objective -C"
A Visual Quickstart Guide by Steve Holzner )
I'm using and I got stuck understanding how 'sizeof' works. (See also
my question below about my needing to figure out how to use
documentation better)
......
The author says that sizeof gets "the size of the whole array". I can
see from displaying each piece of the information that the author
uses, that the calculation using sizeof works, but I don't get what
'sizeof' is sizing? Is is the number of digits it allocates for each
instance in the array?
(the example in the book did not cast - is that the right way to say
it?- but I got compiler warnings and so I added the (long) part). Hope
I have gotten that idea right.
I added the second 2 printf statements. The author clearly thinks I
should be able to figure it out from the first one, which I haven't so
far.
............
#include <stdio.h>
int main()
{
int scores[5] = {92, 72, 57, 98, 89};
printf ("The array is %i elements long.\n", (long) sizeof(scores) /
(long) sizeof(int));
printf ("sizeof(scores) is %i \n", (long) sizeof(scores) );
printf ("(long) sizeof(int) is %i\n", (long) sizeof(int));
return 0;
}
Running…
The array is 5 elements long.
sizeof(scores) is 20
(long) sizeof(int) is 4
Debugger stopped.
Program exited with status value:0.
............. Second question Modern Equiv of older style reference
manual?........
ALSO this brings up one of my challenges. In my history I always had a
nice big fat reference manual where I could look up everything. (I
admit that even in unix, I like a reference manual - though I know how
to do man pages) My guess is that now, I'm supposed to be looking more
at online documentation or documentation within the application
(XCODE) that I'm using. I have a feeling I'm missing something big by
not quite knowing where to go.
I did find the folders with the foundation framework in XCODE, so
that when I go back to working on the OOP side (which I have
temporarily put on the back burner - since I realized I was fighting
my procedural programmer mindset), but that doesn't seem to be where I
find documentation on FUNCTIONS like ' sizeof'.
Thanks for steering my footsteps
Laurel
and running the code examples, and thinking through each line in each
example to make sure I know what each command is doing. Then I try to
make up my own very simple examples in the style of the ones in the
book.
(actually I have 3 books I go between, trying things out, and figuring
out my personal study plan. I tend to work within a particular book
for a couple of weeks. I return back once another author has gotten
me over a stumbling block - self-study ain't easy)
I'm currently working in the most basic of the 3 books ("Objective -C"
A Visual Quickstart Guide by Steve Holzner )
I'm using and I got stuck understanding how 'sizeof' works. (See also
my question below about my needing to figure out how to use
documentation better)
......
The author says that sizeof gets "the size of the whole array". I can
see from displaying each piece of the information that the author
uses, that the calculation using sizeof works, but I don't get what
'sizeof' is sizing? Is is the number of digits it allocates for each
instance in the array?
(the example in the book did not cast - is that the right way to say
it?- but I got compiler warnings and so I added the (long) part). Hope
I have gotten that idea right.
I added the second 2 printf statements. The author clearly thinks I
should be able to figure it out from the first one, which I haven't so
far.
............
#include <stdio.h>
int main()
{
int scores[5] = {92, 72, 57, 98, 89};
printf ("The array is %i elements long.\n", (long) sizeof(scores) /
(long) sizeof(int));
printf ("sizeof(scores) is %i \n", (long) sizeof(scores) );
printf ("(long) sizeof(int) is %i\n", (long) sizeof(int));
return 0;
}
Running…
The array is 5 elements long.
sizeof(scores) is 20
(long) sizeof(int) is 4
Debugger stopped.
Program exited with status value:0.
............. Second question Modern Equiv of older style reference
manual?........
ALSO this brings up one of my challenges. In my history I always had a
nice big fat reference manual where I could look up everything. (I
admit that even in unix, I like a reference manual - though I know how
to do man pages) My guess is that now, I'm supposed to be looking more
at online documentation or documentation within the application
(XCODE) that I'm using. I have a feeling I'm missing something big by
not quite knowing where to go.
I did find the folders with the foundation framework in XCODE, so
that when I go back to working on the OOP side (which I have
temporarily put on the back burner - since I realized I was fighting
my procedural programmer mindset), but that doesn't seem to be where I
find documentation on FUNCTIONS like ' sizeof'.
Thanks for steering my footsteps
Laurel