Page 2 of 2 First 12
  • Jump to page:
    #16
  1. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,378
    Rep Power
    1871
    Well it seems dwise1's first lesson at least rubbed off on you.

    http://stackoverflow.com/questions/1...d-string-scope
    Here you did actually post the whole code rather than some random snippets which could have come from anywhere. You have to understand that every forum gets an awful lot of crap questions, and no doubt had you been equally vague on SO, you would have gotten similar responses regarding posting the real code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  2. #17
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    8
    Rep Power
    0
    Originally Posted by salem
    and no doubt had you been equally vague on SO, you would have gotten similar responses regarding posting the real code.
    I understand your frustrations, however the OP code had zero dependencies, and was completely readable in isolation.

    I agree, that wrapping it in braces made it slightly clearer ( as seen on the stackoverflow post ), but did it warrant the aggressiveness of the response and automatic misinterpretation that the code was completely bogus? - I think not.

    Don't let the bad experiences of 4000+ posts suck away your empathy, because it is not beneficial for anyone ( including yourself ), and certainly doesn't make Dev Shed look good.
  4. #18
  5. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,378
    Rep Power
    1871
    It might have seemed readable to you, but was it a clear and unambiguous description of your question?

    You might think we would just infer 'int main' wrapped around the code, but past experience has taught the old timers here that the code could equally (actually, far more likely to) have been from some heavily cut down larger program, like say
    Code:
    #include <stdio.h>
    
    char* ptr = NULL; 
    
    void magic ( )
    {
    char str[4]={0};
    sprintf(str, "AGH"); 
    
    ptr = str;
    }
    
    int main(void) {
      magic();
      printf("ptr: %s\n", ptr);
      return 0;
    }
    In an effort to be 'helpful', the newbie carelessly removes important information leaving just a minimal stump which they think is the problem.

    I mean, if I'd posted the above program (along with it's garbage output), and I'd said that I can't replicate your program, would you be chewing my ears off as well from not being able to guess what your real program looked like?

    We've been here too long to believe that any 'program snippet' which cannot be compiled just by copy/paste is in any way a meaningful representation of the problem at hand.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo