| « What the GPL v3 isn't | Forking GNU/Linux » |
Sun, Sep 24, 2006
![[Icon]](rsc/img/chain_link.gif)
I just got to the bit about pointers and arrays.
NNNnngg...
So. . . if you want strings, you either have a character array or a character pointer.
So you can define the string "foobar" by either:
char word[]="foobar"
or
char * word="foobar";
And then if you want to change "foobar" to "FooBar", you would use
word[0]='F';word[3]='B';
or
word="FooBar";
respectively. The array changes in-place, but the pointer drops "foobar" from memory and points to the newly-created string "FooBar" stored someplace else in memory.
You run into problems because functions like gets() can't distinguish between arrays and pointers, so always try to change in-place. So if you use gets(word) and the user types "Foooobaaaarrrr", the array would ignore everything that was too long to fit, but the pointer would accept the whole lot, potentially over-writing a piece of memory in use by some other function and causing problems.
So you either have to use arrays, which have fixed lengths and have to be changed character-by-character; pointers which can be any size and can be changed in one go, but you can't use functions like gets(); or a pointer to an array, which can be changed all in one go but can only be as long as the array.
Is that about right?
char foo[] = "foobar";
foo = "Foobar";
Creative Hedgehog
This week has been learning about what a Systems Analyst is, how to think about systems, and to be very aware of gorillas.
Gorillas?
There is a problem with simply asking how the company wants you to solve their problem, or even what they think the problem is. It's called situational blindness, and it [...]
04/03/10 - FIT2001 week 1: beware gorillas!
Hari's corner
How do you awaken a sleepy lawyer in the mornings?
07/03/10 - The Legalease - Episode 10
Place of Stuff
Genesis 19 is a fun little tale, full of reversals and surprises. It begins with two angels going to visit Lot in Sodom. Lot welcomes them in and offers a good foot washing and feeding session. As is polite and in custom with receiving visitors. Especially angels. Shortly after they arrive, the local men turn [...]
27/02/10 - The Bible ? Sod ?Em
Advice From a Single Girl
So I'm kind of in an odd space these days.Still sort of smarting from stuff from a month ago and alternating between wanting to let it go and move on and giving myself time to respect how I'm feeling about it and, well, still being hurt.But I'm also doing pretty well in a lot of ways, I'm feeling good physically and enjoying hanging out with friends and so things are good in some ways too.But
31/12/69 - Ah Me
Nation
 
This was possibly the most ridiculous show I have seen in a long time and I can get Sky 1 I know ridiculous. It could be summed up in three sentences Do you know what's in your cereal? Want to? Read the label. Instead it went on for a hour about how evil the cereal [...]
27/10/09 - Dispatches ? do you know what?s in your breakfast? (warning...
Blogroll generated by MagpieRSS
![[Links]](http://geekblog.oneandoneis2.org/skins/112/rsc/img/chain_link.gif)
Dominic can drive for another year! My little Fiesta survived its ordeal by MOT :).
05/03/10
![]()
I last listened to:
The Offspring - She's Got Issues
Most recent photo:
Submersible houseboat