standards

In C is there any guarantee with code prior to undefined behavior?

人走茶凉 提交于 2020-01-13 08:11:46
问题 In the following code is is guaranteed that "0\n" be printed? #include <stdio.h> int main(void) { int c = 0; printf("%d\n",c); printf("%d,%d\n",++c,++c); } More generally, if a program has undefined behavior does the entire program become undefined or only from the sequence point that begins the problematic code? Please note: I am not asking about what the compiler does with the second printf. I am asking if the first printf is guaranteed to occur. I know that undefined behavior is capable of

What is the Relationship Between the C and C++ Standards?

泄露秘密 提交于 2020-01-12 11:10:50
问题 I was writing this answer and I quoted from http://en.cppreference.com/w/cpp/string/byte/tolower#Parameters Is not representable as unsigned char and does not equal EOF, the behavior is undefined When I went to inspect the edit that had added this phrase I found that the author's comment: Can't use negative signed chars with any ctype.h function per C99 7.4/1 The author is citing from the C99 standard in C++ documentation. Is that valid? I couldn't find anything on the definition of this

What is the Relationship Between the C and C++ Standards?

人走茶凉 提交于 2020-01-12 11:09:42
问题 I was writing this answer and I quoted from http://en.cppreference.com/w/cpp/string/byte/tolower#Parameters Is not representable as unsigned char and does not equal EOF, the behavior is undefined When I went to inspect the edit that had added this phrase I found that the author's comment: Can't use negative signed chars with any ctype.h function per C99 7.4/1 The author is citing from the C99 standard in C++ documentation. Is that valid? I couldn't find anything on the definition of this

What is the Relationship Between the C and C++ Standards?

我的未来我决定 提交于 2020-01-12 11:09:27
问题 I was writing this answer and I quoted from http://en.cppreference.com/w/cpp/string/byte/tolower#Parameters Is not representable as unsigned char and does not equal EOF, the behavior is undefined When I went to inspect the edit that had added this phrase I found that the author's comment: Can't use negative signed chars with any ctype.h function per C99 7.4/1 The author is citing from the C99 standard in C++ documentation. Is that valid? I couldn't find anything on the definition of this

Paypal Payment Standard: Callback URL

余生长醉 提交于 2020-01-12 04:39:08
问题 On Paypal Sandbox: After logging in using a test account and then clicking the "Pay Now" button, the user is redirected to "Thanks for your order" page inside Paypal. The page has three(3) links below the message that says: Return to Test Store Go to PayPal account overview Add funds from your bank Clicking the "Return to Test Store" will redirect me to the return URL I specified on my query string. This marks the order as "Completed" or whatever the value of the payment_status returned by

Where should validation logic be implemented?

早过忘川 提交于 2020-01-12 03:30:07
问题 When developing my interfaces (contracts) and the concrete implementations of them, both the data models as well as repositories, I find myself questioning where the validation logic should go. Part of me (which tends to win out) says that the class itself should be responsible for it's own validation (string max length, date buffers, etc), but the other part of me says this should be moved out to the repository because depending upon the persistence store, these values could change based on

Align <hr> to the left in an HTML5-compliant way

岁酱吖の 提交于 2020-01-11 19:55:16
问题 Currently, I'm using <hr align="left" /> on my HTML5 page, but I've read that the align property was deprecated in XHTML 4.01 and supposedly removed from HTML5. I'd like to be using CSS rather than an inline attribute like this, but when I tried hr{align: left; max-width: 800px;} or hr{text-align: left;} or hr{left: 0;} or hr{float: left;} , it just showed up in the center. So what should I use instead of the inline attribute above? 回答1: You're trying to use something in a way that (as

What differences are expected of XHTML5 versus HTML5?

旧巷老猫 提交于 2020-01-10 07:32:53
问题 What differences are expected of XHTML5 versus HTML5? I understand that XHTML5 is the XML form of the language and HTML5 is the SGML form of the language, which means obvious minor syntax differences. Will there be any further differences? Will XHTML5 deprecate completely worthless elements that were not deprecated by HTML5? Will XHTML5 be written in schema instead of doctype? Will XHTML5 impose structural validations instead of merely stating what is a child of what? Will XHTML5 offer

Global qualification in a class declarations class-head

那年仲夏 提交于 2020-01-10 04:25:20
问题 We found something similar to the following (don't ask ...): namespace N { struct A { struct B; }; } struct A { struct B; }; using namespace N; struct ::A::B {}; // <- point of interest Interestingly, this compiles fine with VS2005, icc 11.1 and Comeau (online), but fails with GCC: global qualification of class name is invalid before '{' token From C++03, Annex A, it seems to me like GCC is right: the class-head can consist of nested-name-specifier and identifier nested-name-specifier can't

What is the rationale for not including strdup in the C Standard?

南楼画角 提交于 2020-01-10 02:35:30
问题 Most C programmers are familiar with the strdup function. Many of them will take it for granted, yet it is not part of the C Standard (neither C89, C99 nor C11). It is part of POSIX and may not be available on all environments. Indeed Microsoft insisted on renaming it _strdup , adding to confusion. It is rather easy to define it this way (in C): #include <string.h> char *strdup(const char *s) { size_t size = strlen(s) + 1; char *p = malloc(size); if (p) { memcpy(p, s, size); } return p; } But