CompuServe Messages

#What's c++

#: 131224 S10/ProgrammingForum unknown
    22-Jun-88 19:13:27
Sb: #131109-#What's c++
Fm: John Foust 72237,135
To: John Draper 76703,4322

This message turned up in search, but its forum couldn’t be identified from the original transcript, so it may not be linked into its thread.

Coming from more strongly typed languages, C's strings and pointers are a bit different. Not wrong or bad, just different. 🙂 If you say "char foo;", you get a character. If you say "char *foo;", you have something that can point to chars. If you have an "APTR foo;", if can point to anything, including characters. The only space allocated is for the size of the pointer itself. Saying "char foo[24];" allocates the space for you, just like dc.b. However, in C, 'foo' by itself can look like a pointer, because in most situations, the address of the first byte in that array is what you want, anyways, like "strcpy( foo, "bah" );" copies "bah" to foo[]. Saying 'char *foo = "bah"' is a different matter, you ask for storage for a char pointer, and then initialize the pointer to point at some static data, namely, "bah" and a zero byte. This all seems so clear to me. 🙂 Re: hopelessly bent. "**foo[*i,**j]" is easy. You can do better than that. That kind of construct is actually quite common on the Mac – be thankful that Amiga memory doesn't shift around a lot. Now, to make it hard, get some pointers to functions in there, that'll toughen it up.