- [OT] Re: Stackoverflow - a fascist web-site. - 18 Updates
- Comparing strings with if else - 1 Update
- Question about math.pi is mutable - 2 Updates
- Question about math.pi is mutable - 3 Updates
- November User Meetings - 1 Update
Paavo Helde <myfirstname@osa.pri.ee>: Nov 07 05:29PM -0600 Vlad from Moscow <vlad.moscow@mail.ru> wrote in > Well, then let you will be banned here because you are not from Russia > and I do not like your answers. It will be indeed the democracy, is > not it?:) In usenet banning is easy and is done via "killfile". I have 3 names in my killfile. Not sure if this is related to democracy in any way. |
Vlad from Moscow <vlad.moscow@mail.ru>: Nov 07 03:50PM -0800 On Saturday, November 7, 2015 at 11:26:46 PM UTC+3, Vlad from Moscow wrote: > As I was already said several times at the same Stackoverflow the problem is that I am from Russia and this is clear from my nickname Vlad from Moscow. > I asked a question at Meta that to discuss the situation but again I was ignored and my question was just removed. > So I am again banned after my correct answer was deliberately down-voted and after I asked a question how to behave in such situations.:) I'd like to append my first post that my answer at Stackoverflow was down-voted in revenge. When I asked the question at Meta what to do when a correct answer is down-voted because moderators had ignored my appeals then at once my answer on C was down-voted several times in spite on the fact that some partipants pointed out that my answer is correct.:) So I was banned that I would not ask such questions any more in the future.:) On the other hand it is enough somebody to complain to me and I am banned at once. Moreover I was called there that I am a prostitute because I answer usually all the questions on C and C++ in a row and nobody was banned after that.:) It is indeed a democracy!:) |
woodbrian77@gmail.com: Nov 07 06:27PM -0800 On Saturday, November 7, 2015 at 2:26:46 PM UTC-6, Vlad from Moscow wrote: > As I was already said several times at the same Stackoverflow the problem is that I am from Russia and this is clear from my nickname Vlad from Moscow. > I asked a question at Meta that to discuss the situation but again I was ignored and my question was just removed. > So I am again banned after my correct answer was deliberately down-voted and after I asked a question how to behave in such situations.:) I've experienced similarly bad behaviour at Stackoverflow. In particular "Bill the lizard" has been, like some in this newsgroup, in denial about the C++ Middleware Writer and on line code generation. Brian Ebenezer Enterprises - If you can't join 'em, beat 'em. http://webEbenezer.net |
Geoff <geoff@invalid.invalid>: Nov 07 07:20PM -0800 On Sat, 7 Nov 2015 12:26:14 -0800 (PST), Vlad from Moscow >My entirely correct answers are purposely down-voted. >Here is a refernce to such a question. >http://stackoverflow.com/questions/33583478/comparing-strings-with-if-else/33583572#33583572 In this particular case at least, your answer is not "entirely correct". You fail to address the inadequate array sizes explicitly. You changed the array size of ckey from 5 to 6 but didn't address the incorrect assignment of char key[5] = "april" which fails to account for the terminating '\0' required in the initialization. You would have been better to correct this to char key[]="april" and let the compiler do the work and to point that out to the OP. Your "comparison" code compares the strings based on the length of key but takes no account of the length of ckey, allowing your comparison to yield true for any ckey beginning with april (e.g., "aprilaaaa") and fails to address the potential for the overflow of the ckey array. You wrote: >char key[5]="april"; >is totally valid in C though is not valid in C++.:) This statement is completely incorrect. It is not valid in C or C++. |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Nov 08 07:04AM +0100 On 11/7/2015 9:26 PM, Vlad from Moscow wrote: > My entirely correct answers are purposely down-voted. > Here is a refernce to such a question. > http://stackoverflow.com/questions/33583478/comparing-strings-with-if-else/33583572#33583572 First, the answer is currently /imperfect/ in that it doesn't explicitly mention the buffer size problem /up front/. That in itself can be enough to trigger a flood of downvotes, from those who are not aware of the technicalities, and when they've committed to downvoting they'll not change their minds. But originally it was much much worse, with no mention at all of that problem until this was added: <quote> P.S. Do not take into account that the answer is down-voted. The reason is that low-qualified beginners like **@Ed Heal**, **@lurker** or **@machine_1** or **@hexasoft** do not know that this declaration char key[5]="april"; is valid in C though is not valid in C++.:) </quote> Now that's a sure-fire way to attract a storm of downvotes. I have on occasion found it probably useful to the community to point out some convincing idiot's technical incompetence, and then I've done it: here, on SO, and elsewhere. I've done that knowing and anticipating the very socially oriented reaction. It sounds like you didn't expect it? * * * Secondly, the answer doesn't discuss how that buffer size is likely a misunderstanding on the part of the OP. Assuming on the one hand, that the OP doesn't know how to compare strings, and at the same time, that the OP intentionally chooses a too small buffer, doesn't hang together, i.e. the answer is /inconsistent/. Now I wouldn't downvote for that but I'd add a comment asking you to fix that, or (perhaps most likely) I'd just edit the answer. * * * To lift a ban on SO you have to be lucky, as I understand it. Attracting votes via old answers. Changing old answers so they turn from downvoted to upvoted. Of course if you're locked out you can't do that. Hm. Cheers & hth., - Alf |
Vlad from Moscow <vlad.moscow@mail.ru>: Nov 07 11:41PM -0800 On Sunday, November 8, 2015 at 6:20:58 AM UTC+3, Geoff wrote: > >char key[5]="april"; > >is totally valid in C though is not valid in C++.:) > This statement is completely incorrect. It is not valid in C or C++. Welcome to the C programming language!:) Now you will know that such a declaration char key[5] = "april"; is totally valid in C.:) And moreover is used very othen in C. If you need not the terminating zero (and in the program that was showed in the question the terminating zero indeed is not needed) then you can declare a character array with a size that trhe initialization will not include the terminating zero in the array. And I pointed to this peculiriaty of C in my answer. And moreover the question was about another problem and that problem is not related to the array initialization. And I showed how to resolve the problem if standard C string functions may not be used. But in any case any particioant could give his own answer to the question where he could describe his own *opinion* about the array initialization. It is only *opinion* because the initialization is correct. What is the matter? Why entirely correct answer is unprecedented so much down-voted? IsStackoverflow a parody on professinal programmers forum where wrong answers are up-voted and correct answers are down-voted?:) What are the tasks of the Stackoverflow? To populate illiteracy? To flood the internet with wrong answer that to confuse programmers who will find answers to their questions in internet? The facts are better any words. A person who gave a correct answer was down-voted and banned.:) It is not the first time when my correct answers are deliberately down-voted without any reasonable explanations that even other participants sometimes write me in comments that it is because you are from Russia.:) |
Bo Persson <bop@gmb.dk>: Nov 08 09:42AM +0100 On 2015-11-08 07:04, Alf P. Steinbach wrote: > To lift a ban on SO you have to be lucky, as I understand it. Attracting > votes via old answers. Changing old answers so they turn from downvoted > to upvoted. Of course if you're locked out you can't do that. Hm. Vlad's page says that it is a limited 1 week ban as a cool off period. It will be lifted automatically when it expires. Hopefully, by then Vlad will have had some time to think this over and realize that calling people names doesn't improve the votes. And that technically correct answers aren't always fully appreciated. Like in politics, you get many votes for simple solutions that people understand. Really advanced answers can get just 1 or 2 upvotes from those who understand it, while a simple quote from the language standard can get you a hundred upvotes. That's life. Bo Persson |
Vlad from Moscow <vlad.moscow@mail.ru>: Nov 08 01:08AM -0800 On Sunday, November 8, 2015 at 11:43:04 AM UTC+3, Bo Persson wrote: > those who understand it, while a simple quote from the language standard > can get you a hundred upvotes. That's life. > Bo Persson I was going to provide a refernce to the C Standard and usually my answers begin with such a reference. But first of all the question was not about character arrays initializations in C and 1) the behaviour of whose who dwon-voted was so aggressive that they did not want to listen to the reason and 2) I had not at hand the open C Standard at that moment. On the other hand whose who down-voted also could give a reference to the Standard if they think that my answer is in essence wrong. But nine down-votes say themselves that nobody was going to do that.:) |
Ben Bacarisse <ben.usenet@bsb.me.uk>: Nov 08 11:40AM > Now you will know that such a declaration > char key[5] = "april"; > is totally valid in C.:) And moreover is used very othen in C. Yes, it's valid but I would not say it's often used. I can't remember the last time I saw such a thing "in the wild", whereas initialisations that include the null are very common indeed. <snip> > Why entirely correct answer is unprecedented so much down-voted? It's not "entirely correct" because the question was about comparing strings, and char key[5] = "april"; is not a string -- it's a just a character array. (7.1.1 p1 "A string is a contiguous sequence of characters terminated by and including the first null character.") It's also possible that some of the reaction was because your answer was a bit left-field. To do the comparison with a non-string, using the size to terminate the loop, is not idiomatic C. The code is correct in that it works, but it would be unlikely to pass a code review in most companies. I would not have down-voted the answer, but I'd have added a comment about the non-idiomatic code and that fact that key not a string. <snip> -- Ben. |
cdalten@gmail.com: Nov 08 03:50AM -0800 Well this is kind of new and exciting. |
Vlad from Moscow <vlad.moscow@mail.ru>: Nov 08 05:32AM -0800 On Sunday, November 8, 2015 at 2:40:35 PM UTC+3, Ben Bacarisse wrote: > <snip> > -- > Ben. The question is not about how to compare strings. The question is about how to compare the content of the given character array key that initialized wiith 5 characters with entered 5 characters without using any other library functions. And I showed how it can be done. And the solution is correct. If you think that there is another better solution then what is the matter? Write your own answer! But do not down-vote a correct answer if you even do not know how character arrays may be initialized in C. At least you always may ask in a comment why is there used such an initialization. And moreover it was not my code. This initialization initially was in the code example of the question. It is a correct initialization. So as there is no any need to compare character strings as you are saying then I did not discuss this aspect. I answered directly the question. And again you (of course I mean any participant not personally you) always may write you own answer. And maybe your answer will be marked as the best by the author of the question. To achieve this there is no any need to down-vote correct answers. Otherwise you are simply confusing others. |
Ben Bacarisse <ben.usenet@bsb.me.uk>: Nov 08 01:56PM >> >> On Sat, 7 Nov 2015 12:26:14 -0800 (PST), Vlad from Moscow <snip> >> >> >http://stackoverflow.com/questions/33583478/comparing-strings-with-if-else/33583572#33583572 <snip> > On Sunday, November 8, 2015 at 2:40:35 PM UTC+3, Ben Bacarisse wrote: >> Vlad from Moscow writes: <snip> >> > Why entirely correct answer is unprecedented so much down-voted? >> It's not "entirely correct" because the question was about comparing >> strings, and char key[5] = "april"; is not a string <snip> > The question is not about how to compare strings. It was called: "Comparing strings with if else" You can, I hope, see why some people might think the question was about strings? <snip> -- Ben. |
Vlad from Moscow <vlad.moscow@mail.ru>: Nov 08 06:54AM -0800 On Sunday, November 8, 2015 at 4:56:43 PM UTC+3, Ben Bacarisse wrote: > <snip> > -- > Ben. Very often titles of questions do not reflect the contents and the meanings of the questions. Many programmers incorrectly call any character array like a string. The question is not the title. The question is its content. There are given starting conditions and using these conditions I showed how the task can be done. And my solution does not contradict these conditions. My answer contains nothing wrong. If you think that the author of the question should initialize the array in ther way you should address this question to the athor. If the author indeed need a string then I do not see the meaning of the condition not to use library functions. I pointed out that he could use either strncmp or memcmp. If his character array had the terminating zero then in this case I would advice to use for example standard function strcmp. So the question has more meaning when the character array has no the terminating zero. Otherwise it is too trivial. But in any case my answer was not down-voted because I suggested something wrong. My question was down-voted because who want to dwon-vote it found an articificial reason to do this. This reason is not related to my solution. Do you think that nobody knew there how character arrays are initialized in C? For example if I see a somebody's wrong statement I try to correct he. It was an attack against me. As somebody betrayed himself in a comment that was deleted by the moderator it was a war against me. I am sure that my answer would break the record of the number of down-votes if it was not locked.:) All is fair in war. Is not it is the main principle of the democracy?:) Now my locked answer is the symbol of the democracy and Stackoverflow: do you want the democracy?! When you will be banned!:) My congratulations.:) |
"Öö Tiib" <ootiib@hot.ee>: Nov 08 07:46AM -0800 On Saturday, 7 November 2015 22:26:46 UTC+2, Vlad from Moscow wrote: > My entirely correct answers are purposely down-voted. > Here is a refernce to such a question. > http://stackoverflow.com/questions/33583478/comparing-strings-with-if-else/33583572#33583572 The question seems to be about how to make "security". The code posted in question manages to contain several silly defects. Your answer explains somewhat the issues and provides some code that at least works. > Sometimes it can be that somebody does not agree with your answer. But > usually he points the reason of the disagreement in his comment and I > can provide a reference to the C Standard that to prove my point of view. Good idea! I suspect you got most of the down-votes thanks to not showing how standards support you but instead you did build some "low qualified beginners" lists in your answer and even had edit wars about those. > On the other hand if I down-vote somebody's incorrect answer and even > write in a comment what is wrong in the answer then instantly a > complain follows to moderators and I am banned. The site is seemingly not designed for too deep discussions, fights and name calling that you did. Giordano Bruno was burned on stake for opposing some official views 315 years ago. Few down votes and bans for name calling in moderated q/a site ... do you feel that you were treated as unfairly as Giordano Bruno? > As I was already said several times at the same Stackoverflow the problem > is that I am from Russia and this is clear from my nickname Vlad from Moscow. You seem correct but what we can do? That issue is clearly outside of our competence. > I asked a question at Meta that to discuss the situation but again I > was ignored and my question was just removed. > So I am again banned after my correct answer was deliberately down-voted and after I asked a question how to behave in such situations.:) Forget that stack overflow. Do something else. You are bright guy and can certainly make some software more correct or easier to use. |
Rosario19 <Ros@invalid.invalid>: Nov 08 07:00PM +0100 On Sat, 7 Nov 2015 12:26:14 -0800 (PST), Vlad from Moscow >My entirely correct answers are purposely down-voted. >Here is a refernce to such a question. >http://stackoverflow.com/questions/33583478/comparing-strings-with-if-else/33583572#33583572 int main( void ){ char key[5]="april",ckey[6]; printf("Enter the key: "); scanf("%5s",ckey); size_t i = 0; while ( i < sizeof( key ) && key[i] == ckey[i] ) ++i; if( i == sizeof( key ) ){ printf("Correct."); } else{ printf("Wrong."); } return 0; } do you try that code? it seems ok this: >vlad Enter the key: aprilMy Correct. ---------------- but is good sizeof(key) or it is better (sizeof key) than has not to be written one "\n" as last char for output? this is my version #include <stdio.h> int main(void) {char key[]="april",ckey[8]; unsigned i; int r; printf("Enter the key: "); r=scanf("%7s",ckey); for(i=0 ; key[i]==ckey[i]&&key[i]!=0 ; ++i) ; if(key[i]==0&&ckey[i]==0&&r==1) printf("Correct.\n"); else printf("Wrong. \n"); return 0; } |
Rosario19 <Ros@invalid.invalid>: Nov 08 07:09PM +0100 On Sun, 08 Nov 2015 19:00:21 +0100, Rosario19 wrote: > else printf("Wrong. \n"); > return 0; >} find one error #include <stdio.h> int main(void) {char key[]="april",ckey[8]; unsigned i; int r; printf("Enter the key: "); fflush(stdout); r=scanf("%7s",ckey); for(i=0 ; key[i]==ckey[i]&&key[i]!=0 ; ++i) ; if(key[i]==0&&ckey[i]==0&&r==1) printf("Correct.\n"); else printf("Wrong. \n"); return 0; } |
asetofsymbols@gmail.com: Nov 08 10:38AM -0800 That place wrote: ---------- Oops! Your answer couldn't be submitted because: *Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon. *An email is required to post. ------- The code is intended ok 4 spaces for indent are too much |
Bo Persson <bop@gmb.dk>: Nov 08 09:11PM +0100 > ------- > The code is intended ok > 4 spaces for indent are too much It's not 4 spaces indents in the code, it is 4 spaces at the beginning of each line to have it rendered as code. The spaces will not show. You can add the 4 spaces, or mark the code and press Ctrl+K, or click the code formatting icon above the text box. Bo Persson |
Richard Damon <Richard@Damon-Family.org>: Nov 08 03:05PM -0500 On 11/8/15 9:29 AM, Stefan Ram wrote: > { return > *s ?( *s1 ? *s == *s1 && isequal( s + 1, s1 + 1 ): 0 ): > *s1 ? 0 : 1; } I would simplify this to: return *s == *s1 && (*s ? isequal( s+1, s1+1) : 1); |
Thomas Kempkes <thomas@familie-kempkes.de>: Nov 08 10:11AM +0100 > impossible to define a const correct strstr. But in C++ I have expected > that according to the overload, the const version of strstr would be > selected (http://www.cplusplus.com/reference/cstring/strstr/ ) . Still: [... code snipped] > Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) > Target: x86_64-apple-darwin12.6.0 > Thread model: posix $ g++ -Wall const_test.cc const_test.cc: In function 'int main()': const_test.cc:7:34: error: invalid conversion from 'const char*' to 'char*' [-fpermissive] char *p = strstr(name, "Tom"); // this line should be an error ^ If I want to be as close to a the standard as possible I usually use -Wall -Wextra -ansi -pedantic with my g++, but in this case it wasn't even necessary, so just use a decent c++ compiler and this code won't even compile. My compiler version: $ g++ --version g++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Let me add that I really like to use as many consts as possible (but no more). I know it is PITA to add them to an existing codebase, so be sure to add them directly when writing the code. If you have to "sprinkle type casts around your code" your design is definitly broken! In our code with many hundred thousends lines of hand written code there are 5 const_casts, I think. There is none in the generated code I know of. > Christian BYe Thomas -- Tomorrow is another day, but it'll suck, too... |
ram@zedat.fu-berlin.de (Stefan Ram): Nov 08 02:29PM There are many ways, but today I want to do it the LISP way! #include <iostream> #include <ostream> constexpr bool isequal ( char const * const s, char const * const s1 ) { return *s ?( *s1 ? *s == *s1 && isequal( s + 1, s1 + 1 ): 0 ): *s1 ? 0 : 1; } int main() { ::std::cout << isequal( "", "" )<< '\n'; ::std::cout << isequal( "ab", "ab" )<< '\n'; ::std::cout << isequal( "a", "a" )<< '\n'; ::std::cout << isequal( "a", "b" )<< '\n'; ::std::cout << isequal( "ab", "ac" )<< '\n'; ::std::cout << isequal( "a", "" )<< '\n'; ::std::cout << isequal( "", "a" )<< '\n'; } |
Christian Gollwitzer <auriocus@gmx.de>: Nov 08 09:00AM +0100 Am 08.11.15 um 08:45 schrieb Marko Rauhamaa: > $ ./prog > Bob > No warning. That is strange. In C, I can see thet problem here, because it is impossible to define a const correct strstr. But in C++ I have expected that according to the overload, the const version of strstr would be selected (http://www.cplusplus.com/reference/cstring/strstr/ ) . Still: apfelkiste:Tests chris$ cat prog.cpp #include <cstdio> #include <cstring> int main() { const char name[] = "Tom"; char *p = strstr(name, "Tom"); // this line should be an error strcpy(p, "Bob"); printf("name = %s\n", name); return 0; } apfelkiste:Tests chris$ g++ -Wall prog.cpp apfelkiste:Tests chris$ ./a.out Bus error: 10 It segfaults because on OSX, const can be stored in write-only memory. apfelkiste:Tests chris$ g++ --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) Target: x86_64-apple-darwin12.6.0 Thread model: posix Christian |
Paavo Helde <myfirstname@osa.pri.ee>: Nov 08 02:54AM -0600 Christian Gollwitzer <auriocus@gmx.de> wrote in news:n1mvak$660$1@dont- email.me: >>> But it allows the compiler to warn you if you pass a pointer to a >>> read-only data to a function that expects a pointer to writable data. >> Unfortunately, it doesn't: ======================================================================== >> printf("name = %s\n", name); >> return 0; >> } ======================================================================== > const char name[] = "Tom"; > char *p = strstr(name, "Tom"); // this line should be an error > strcpy(p, "Bob"); strstr() and strcpy() are not guaranteed to be present when you include <cstring>, one should use std::strstr() and std::strcpy() instead. But this is probably not important here. > apfelkiste:Tests chris$ ./a.out > Bus error: 10 > It segfaults because on OSX, const can be stored in write-only memory. FWIW, MSVC 2013 produces an error: 1> main.cpp 1>main.cpp(6): error C2440: 'initializing' : cannot convert from 'const char *' to 'char *' 1> Conversion loses qualifiers 1>main.cpp(7): error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC \include\string.h(112) : see declaration of 'strcpy' ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== |
Ian Collins <ian-news@hotmail.com>: Nov 08 10:03PM +1300 Christian Gollwitzer wrote: > printf("name = %s\n", name); > return 0; > } You must be using an old compiler: # gcc4.9/bin/g++ x.cc x.cc: In function 'int main()': x.cc:7:31: error: invalid conversion from 'const char*' to 'char*' [-fpermissive] char *p = strstr(name, "Tom"); // this line should be an error -- Ian Collins |
woodbrian77@gmail.com: Nov 07 05:51PM -0800 23 C++ User Group meetings in November by Jens Weller 4th Saint Louis - Unit Test++, Scott Meyers "gotchas", group exercise 4th Washington, DC - Q & A / Info Sharing 4th Austin - OpenMP 9th Edinburgh 9th Zentralschweiz - Coding Dojo 11th Utah 11th San Francisco - Presentation and Q&A 12th NRW/Aachen - Variadic Templates und TMP ohne Rekursion 12th Dresden - User perspektive on Catch 16th Austin - Monthly C/C++ Pub Social 17th Berlin 17th Hamburg - OpenCL 18th San Francisco - Workshop and Discussion Group 18th Warsaw - LLVM a jakość i bezpieczeństwo oprogramowania 18th Washington, DC - Q & A / Info Sharing 18th Bristol - Thomas Guest 18th Düsseldorf - Lightning Talks 18th Seattle - CppCon Keynote - Bjarne Stroustrup 18th Sacramento - First Meetup 25th San Francisco - Workshop and Discussion Group 26th Rhein-Neckar - C++11/C++14 loops of fun 26th Bremen 26th Munich - Lightning Talks If others are interested in a C++ meeting in the St. Paul, Minnesota area, please let me know. By the grace of G-d, I'm able to provide a meeting area in a conference room in the office building where Ebenezer Enterprises is, and I would be happy to give a talk or two. Brian Ebenezer Enterprises - In G-d we trust. http://webEbenezer.net |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment