standards

Do string literals that end with a null-terminator contain an extra null-terminator?

半世苍凉 提交于 2019-11-28 19:07:19
For example: char a[] = "abc\0"; Does standard C say that another byte of value 0 must be appended even if the string already has a zero at the end? So, is sizeof(a) equal to 4 or 5? All string literals have an implicit null-terminator, irrespective of the content of the string. The standard (6.4.5 String Literals) says: A byte or code of value zero is appended to each multibyte character sequence that results from a string literal or literals. So, the string literal "abc\0" contains the implicit null-terminator, in addition to the explicit one. So, the array a contains 5 elements. 来源: https:/

Understanding the C11 type hierarchy

↘锁芯ラ 提交于 2019-11-28 18:40:56
问题 I would like to fully understand type hierarchy of the C11 language and present it graphically (a tree diagram would be perfect). The standard does not provide any figure for this issue – there are 30 points describing individual types and relations between them. I'd like to draw it. My attempt started from obtaining the ISO/IEC 9899:201x Committee Draft N1570 and extracting all the essential statements from section 6.2.5 of the document. Then, I started to rearrange the knowledge in a form

Why is javascript the only client side scripting language implemented in browsers? [closed]

拟墨画扇 提交于 2019-11-28 18:06:20
Why don't browsers add support for, say, Python scripting as an alternative to Javascript? Or more general purpose scripting languages? Is there a reason that Javascript is the only one implemented across browsers? After all, the script tag does have support to specify the scripting language used. (I know there is VBScript support in IE, but it seems obsolete for all intents and purposes.) Well, Google is trying to buck that trend with Dart . The community hasn't been entirely receptive to the idea; either. Google proposed adding multiple VM support for Webkit which didn't go down very well.

Set element width or height in Standards Mode

℡╲_俬逩灬. 提交于 2019-11-28 17:41:22
Is it possible to set width or height of HTML element (ex. <div> ) in JavaScript in Standards Mode? Note the following code: <html> <script language="javascript" type="text/javascript"> function changeWidth(){ var e1 = document.getElementById("e1"); e1.style.width = 400; } </script> <body> <input type="button" value="change width" onclick="changeWidth()"/> <div id="e1" style="width:20px;height:20px; background-color:#096"></div> </body> </html> When user presses the change width button, the <div> 's width should change. It works fine when doctype declaration determines Quirks Mode. In

How to correctly compute the length of a String in Java?

馋奶兔 提交于 2019-11-28 17:39:57
问题 I know there is String#length and the various methods in Character which more or less work on code units/code points. What is the suggested way in Java to actually return the result as specified by Unicode standards (UAX#29), taking things like language/locale, normalization and grapheme clusters into account? 回答1: The normal model of Java string length String.length() is specified as returning the number of char values ("code units") in the String. That is the most generally useful

Latest changes in C11

天涯浪子 提交于 2019-11-28 17:28:15
C1x has become ISO/IEC 9899:2011 aka C11. Does anyone know what changes (if any) there are in the Standard from the April 2011 draft n1570 ? ETA: There are the Committee minutes from London (March 2011) (which should be included in n1570) here , and from Washington, DC (October 2011) here ; I suppose a list of accepted changes in the DC minutes should cover things. I just learned today that there was one (somewhat) significant change between N1570 and the final C11 standard (ISO/IEC 9899:2011 (E)). In N1570, 6.3.2p3 says: Except when it is the operand of the sizeof operator, the _Alignof

For { A=a; B=b; }, will “A=a” be strictly executed before “B=b”?

我与影子孤独终老i 提交于 2019-11-28 17:22:15
问题 Suppose A , B , a , and b are all variables, and the addresses of A , B , a , and b are all different. Then, for the following code: A = a; B = b; Do the C and C++ standard explicitly require A=a be strictly executed before B=b ? Given that the addresses of A , B , a , and b are all different, are compilers allowed to swap the execution sequence of two statements for some purpose such as optimization? If the answer to my question is different in C and C++, I would like to know both. Edit: The

Existing Standard Style and Coding standard documents [closed]

吃可爱长大的小学妹 提交于 2019-11-28 17:19:22
The following have been proposed for an upcoming C++ project. C++ Coding Standards, by Sutter and Alexandrescu JSF Air Vehicle C++ coding standards The Elements of C++ Style Effective C++ 3rd Edition, by Scott Meyers Are there other choices? Or is the list above what be should used on a C++ project? Some related links Do you think a software company should impose developers a coding-style? https://stackoverflow.com/questions/66268/what-is-the-best-cc-coding-style-closed Harald Scheirich I really think it does not matter which one you adopt, as long as everyone goes along with it. Sometimes

Is std::stoi actually safe to use?

时光怂恿深爱的人放手 提交于 2019-11-28 17:09:41
I had a lovely conversation with someone about the downfalls of std::stoi . To put it bluntly, it uses std::strtol internally, and throws if that reports an error. According to them, though, std::strtol shouldn't report an error for an input of "abcxyz" , causing stoi not to throw std::invalid_argument . First of all, here are two programs tested on GCC about the behaviours of these cases: strtol stoi Both of them show success on "123" and failure on "abc" . I looked in the standard to pull more info: § 21.5 Throws: invalid_argument if strtol, strtoul, strtoll, or strtoull reports that no

What is the best practice when using UIStoryboards?

百般思念 提交于 2019-11-28 17:06:01
Having used storyboards for a while now I have found them extremely useful however, they do have some limitations or at least unnatural ways of doing things. While it seems like a single storyboard should be used for your app, when you get to even a moderately sized application this presents several problems. Working within teams is made more difficult as conflicts in Storyboards can be problematic to resolve (any tips with this would also be welcome) The storyboard itself can become quite cluttered and unmanageable. So my question is what are the best practices of use? I have considered using