Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Remove the "no URL till 2nd post" restriction? on: January 23, 2011, 07:57:48 pm
Nothing is stopping me. I already made my second post, with links, in the topic I wanted to post to.

I didn't know I'd be able to edit and add links. The error message might have told me...

Since I didn't want to make an empty off-topic post for my first post, I decided to write an on-topic post... hence the above post/suggestion.
2  Forum 2005-2010 (read only) / Bugs & Suggestions / Remove the "no URL till 2nd post" restriction? on: January 23, 2011, 03:36:29 pm
I'm posting this because I want to post a documentation-bug-report about the website, but I can't include the URL until my 2nd post. Argh.
3  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: [No!] Web doc bug: adding \0 to char array?? on: January 23, 2011, 04:32:40 pm
Thanks, Dave. You're right, and I've edited my post.

I thought the doc was saying that the \0 would be added for some string-specific reason. It was not saying that, of course.
4  Forum 2005-2010 (read only) / Bugs & Suggestions / [No!] Web doc bug: adding \0 to char array?? on: January 23, 2011, 03:36:36 pm
[Edit: This post is wrong. C does initialize static storage to 0. But it also (which I didn't know) fills out partially-specified arrays with 0. So there's no problem with the documentation.]

The documentation at http://www.arduino.cc/en/Reference/String for "char *" type strings claims that this is a valid string initialization:

char Str2[8] = {'a', 'r', 'd', 'u', 'i', 'n', 'o'};

It further claims that the compiler will add the (almost always desired) \0 character to the end.

I think this is subtly wrong. If Str2 is a static (e.g. global) variable, then the 8th position would be cleared to 0 - just like any static variable - and it wouldn't matter that you didn't initialize it. So in this case, it looks like the compiler added the \0 to the initialization array.

But if Str2 were declared as a function local variable, I think the 8th position would be stack garbage.

At least, that's the case in C. Maybe C++ is different, but it still seems like a shady thing to teach programmers to depend on.

Consider this declaration:

char Str7[7] = {'a', 'r', 'd', 'u', 'i', 'n', 'o'};

Should the compiler add a \0 to this? Obviously not.
Pages: [1]