CompuServe Thread

Forum unknown · Programming

#What's c++

1 messages in this thread
#131224From: John FoustJun 22, 1988 7:13 PM
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.