Computer SW Languages C_Cplusplus - Berkeley CSUA MOTD
Berkeley CSUA MOTD:Computer:SW:Languages:C_Cplusplus:
Results 151 - 300 of 415   < 1 2 3 >
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2024/12/25 [General] UID:1000 Activity:popular
12/25   

2005/2/15-16 [Computer/SW/Languages/C_Cplusplus] UID:36176 Activity:kinda low
2/15    Is there some library available to make Unix network programming
        in C easier?  I just need to do some very simplistic socket
        communication, but the APIs described in Steven's Unix Network
        Programming books are a real pain.
        \_ C or C++?  wxWindows has a socket library.
           \_ C, wxWindows?
              \_ Which is why I asked if it really was C.
        \_ There is no such thing as simplistic socket communication.
           \_ use IO::Socket;  $s = new IO::Socket::INET "host:port";
              How much simpler do you want?
        \_ sdl_net at http://www.libsdl.com is an example of a very simplfied network
           library; it is written in C. There are plenty of others out there but
           that is the first one that comes to mind.
2005/2/15-16 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Compilers] UID:36174 Activity:moderate
2/15    Technical question:  we have a memory leak in our C code, we think,
        but it's not the sort of memory leak where the memory's unreferenced.
        What we'd like to do is sort of a poor-man's profile, we want
        to know who calls our memory allocator "New"...  Sorta like a stack
        trace.  Using an actual profiler is sort of difficult 'cause it's
        a parallel application.  Thanks,  --peterm
        \_ Not sure about parallel application, but how about looking into
           ccured? It reads in code, analyzes it, then generates another C code
           with annotation that could be useful. Never used it myself though.
        \_ I've heard very good things about Purify but it is not free. Also
           take a look at other tools used for Mozilla development:
           http://www.mozilla.org/projects/xpcom/MemoryTools.html
           Please tell us which tools you ended up using and what you thought
           about it, thanks!
           \_ seconded.  it's been years, but I recall purify being able to
              summarize how much memory was allocated by what code very much
              like op is asking, e.g. counts of how many times a particular
              calling context was used to hit malloc.  don't recall whether
              there were limits to how many levels of caller it tracked.
        \_ What is your platform (OS, version, etc.)?  What is your compiler
           (vendor, version, etc.)?
            \_ It's definitely a problem with our code.  Three compilers,
               3 platforms:  gcc 3.2 linux, HP cc on 21264, xlc on AIX.
               \_ The Boehm Collector is free, and can be used to detect leaks.
                  http://www.hpl.hp.com/personal/Hans_Boehm/gc
        \_ valgrind is free, Linux only
           \_ I thought you said Viagra
2005/2/7-8 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Compilers, Computer/SW/WWW/Browsers] UID:36090 Activity:moderate
2/7     http://www.cs.ucla.edu/~kohler/pubs
        Read the first paper. Not too technical and quite readable. I hope
        it gets accepted into the prestigious WMCS, C&I conference.
        \_ That rules.
        \_ i guess it's nice to know that it's not just me.
           \_ Heh, ditto that. Maybe Phillip should write up a more in-depth
              study on the subject?
        \_ Cute.
        \_ The log graph on page 10 rocks.
        \- Did you actually submit that?
           \_ PROFESSOR Kohler doesn't have a csua account.
2005/1/28-30 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Editors/Emacs, Computer/SW/Editors/Vi] UID:35967 Activity:very high
1/28    emacs question: How can I specify a keyboard combo for saving
        the file? I find "control x  s" awkward. I would like to use
        "control x  \" instead.
        \_ put this in your .emacs:
           (global-set-key "\C-x\"" 'save-buffer)
           to get rid of C-xs for saving, you can use:
           (global-unset-key "\C-xs")
            \_ Thank you. That's awesome. I tweaked it like this:
                (global-set-key "\C-x\C-\\" 'save-buffer)
                Now it works great. Thanks!
                Now it works great just like jove. Thanks!
        \_ As someone who's switched from jove to emacs (many years ago),
           and also from random package X to random package Y, I urge you
           to learn and use the default bindings. If you don't, you can't
           ever use the package outside of your own environment; your buddy
           says, hey, here, fix this piece of code in my buffer, and you
           can't move the cursor because you defined the move-cursor commands
           to be like the Doom bindings ...    -- one who's been there
           \_ Seconded. I also recommend learning vi to the point
              where you are comfortable editing code using it b/c
              one day you will end up crunched for time and stuck
              on a box w/o emacs and the last thing you want to
              worry about is how to insert text.
              \-In the case of C-xC-s/C-xs, I think it is a good idea
                to stick to those bindings unless there is some weird
                reason not to [like C-q/C-s lossage]. In some other cases
                it may be reasonable to swtich. You know there is nothing
                that says you have to unset C-xs ... I suppose since C-x\
                is not normally bound having both isnt too bad. Re: vi ...
                you probably want to be able to use vi enough to get
                emacs running and do basic edits but that is a long way
                from being able to edit code. In fact the whole approach
                to editing code is different between emacs and vi, so if
                you see them as interchangable [do i use ESC-l, or C-f to
                move to the right], then you are likely not using emacs
                correctly/fully [e.g. M-x compile etc]. --mr. emacs
                \_ My emacs session generally has mh-rmail, gnus,
                   w3c, gdb, compiles and dozens of buffers open
                   at any given time. At one point in my life I
                   used to use emacs client/server regularly.
                   However, I still think that knowing how to switch
                   btwn emacs and vi is a valuable skill (ex i is to
                   insert, a is to append, hjkl is to move, :1 is
                   first line, G is last line, / to pattern match,
                   % is to paren match, this will be good enough
                   for 95% of all problems).
                   \- By all means go for the "95%" but that is a
                      long way from "I am comfortable working on
                      large projects in either emacs or vi and
                      merely prefer emacs."
2005/1/21-22 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Java] UID:35849 Activity:high
1/21   Thought this was an interesting read:
       http://paulgraham.com/noop.html
       I tend to agree with him, as I've seen relatively little gain
       from such languages as C++ and Java in terms of creating better
       software.
        \_ I thought it was pretty sophomoric, really.  OOP is a tool that is
           often used poorly.  If used well, his comments are all wrong.  But
           that's the same of any technique.
           \_ Actually, I think you missed the point. If a tool is often used
              poorly, then why do we have the tool in teh first place? i.e.
              if a hammer is poorly designed so that people use it the wrong
              way, get rid of the hammer and find a better one. OO is often
              used poorly because it's been designed poorly. I.e. people
              think it's "cool" to use C++ or Java to program in because
              it's got wonky crap features in it like templates and
              object overloading and container classes. There are so many
              tacked on features in Java nad C++ now that you need tomes
              and tomes of printed material to just document the stuff.
              So programming becomes basically a websearch project, which
              it shouldn't really be. We don't need six layers of abstraction
              to get to pushing bits over TCP/IP. We also don't need
              six layers of abstraction to calculate the cost of a pair of
              shoes being bought online.
              \_ Ok, I'm not pp, and have absolutely *no* opinion on the
                 relative merits of C or C++ or Java or whatever, but I have
                 to say something about your tool comment.  In my observation,
                 the *vast* majority of people do not know how to use a toilet
                 plunger correctly.  Does that mean we don't need toilet
                 plungers?  Can you suggest a superior tool for the job?
                 One other solution is to have a basket full of pointy sticks
                 next to the toilet which users can use to break up their turds
                 with a stabbing motion.  This is certainly a more
                 self-expanatory tool, but it is also inferior.  First of all,
                 it doesn't help you if the offending turd has already passed
                 the U-bend, and second of all, it leaves you with a shit
                 covered stick that you have to dispose of.
              \_ Hehe.  Wonky features like container classes.  I think the
                 fault of C++ is not the amount of features it has (most
                 of them are there for a reason) but the way they fail to
                 come together as a coherent, organic whole.  Stroustrup is
                 a smart guy, but an artist he is not.  It's telling that
                 you think Java is featureful, Java is one of the most
                 featureless languages I know of. -- ilyas
                 \_ Well Strou built it on C so it can't really help being
                    ugly. It feels like it wants to be another language but
                    it lives in C land for practicality. Kind of how Windows
                    lived in MS-DOS for so long.
              \_ In the US of A, we have the FREEDOM to use C++ poorly
              \_ No, I didn't miss the point.  The point is crappy OOP gives
                 crappy results.  OOP used well has huge benefits.  That's the
                 difference between a beginner and an experienced SE.
2004/12/20-25 [Computer/SW/Languages/C_Cplusplus] UID:35366 Activity:nil
12/20   Looking for skilled, full-time C or C++ software developer, working
        with network simulation software.  In L.A.  See /csua/pub/jobs/snt.
        \_ With an office environment like that:
           "We really don't have any cubicles with tall walls - you'll probably
           have your own 6' folding table, sharing a room with 2-5 other
           developers."
           Who wouldn't want to work there!
           \_ Yeah ... we are evaluating moving to a bigger office next door,
              I guess I'll update the posting if that becomes imminent.
2004/12/14 [Computer/SW/Languages/Perl, Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Misc] UID:35286 Activity:insanely high
12/13   http://khason.biz/blog/2004/12/why-microsoft-can-blow-off-with-c.html
        Why Microsoft Can Blow Off with C the Language (humor/funny)
                                                       \_ not really.  -tom
             that's because tom holub is the anonymous humourless nuker _/
        \_ Feel the babelfish flow through you.
        \_ Any body who thinks Fortran hasn't seen widespread acceptance hasn't
           spent much time outside of the world of software development and
           systems administration, methinks. Out where I do my civil
           engineering thing, Fortran is the standard langauge. -- ulysses
        \_ Not the law is clear? There is a beard - there is a success.
           There is no beard - you are guilty.
2004/12/9-10 [Computer/SW/Languages/C_Cplusplus] UID:35232 Activity:high
12/9    What is the option for gcc to allow C++ style comments for
        C files? -TIA
        \_ They're allowed by default.  You can disable them with -ansi, if
           you want.  --mconst
           \_ oh. the wind river gcc must have -ansi on by default.
2004/12/8-9 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages] UID:35217 Activity:kinda low
12/8    When people say null string or empty string in C, does it mean a char
        pointer that's NULL, or a char array whose first char is '\0'?  Thanks.
        \_ Both, because it's essentially the same. However, I think they
           probably mean the latter. I assume you mean a pointer pointing
           to NULL, and not a pointer which is NULL, which makes no real
           sense.
           \_ What's I'm thinking is that for "char *str", it can be either
              "str == NULL" or "str[0] == '\0'".  So you're saying that for the
              former, there is no string; and for the latter, there is a string
              but it's a null/empty string.  Correct?
              \_ Possibly, but if you were to malloc a string and assign
                 its lvalue to *str's rvalue then str==null means that
                 you are checking to see if you lost the rvalue for the
                 str. So theoretically the string could still exist if
                 it hadn't been probably freed and you'd have a
                 memory leak. For the latter if you created an automatic
                 character array the memory stays assigned to str regardless
                 of terminating it at the beginning. There is no way to
                 release the memory for an automatic variable unless you
                 do something really wonky. So neither really checks for
                 a lack of a string. The former checks to see if the pointer
                 is pointing to a string, the second checks to see if the
                 first char of a string is the terminator.
        \_ The latter.  "Empty string" is a better term to use than "null
           string".
           \_ I always assumed that an empty string is a string that exists
              but is empty, ie "", and that NULL string refers to the case
              where the string pointer is NULL.  /me shrugs
              \_ Typically you see this as char* p = NULL.
                 p is a char pointer.  p points to NULL.
        \_ If the term uses "string", that means it's NUL-terminated.
           Therefore it means "".  A char* that's NULL is a null pointer.
           But probably prefer "empty string" for clarity.
           \_ You mean a char* that points to NULL. a char* that is NULL,
              well, that doesn't exist. Since an array is passed like
              a char* in C, a string which is "" is essentially the
              same a char* pointing to NULL.
              \_ Err, yeah.  I think you might want to rethink that position.
              \_ What?  The previous poster's explanation and terminology
                 was correct.
              \_ char* cptr = NULL; // null pointer
                 char* cptr = ""; // empty string (== "null string" (?))
                                  // "" is \0 in memory.
                 Those aren't the same. You can deference the empty string.
2004/12/8 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Java] UID:35214 Activity:very high
12/8    For person who wanted to know how to overload new[], the general
        syntax is void * operator new[](size_t) { //do whatever you need to
        do with size_t and return an array pointer } -williamc
        \_ And if you're going to do this madness, be sure to overload delete[]
           as well.
        \_ Cool, thanks.  Now I remember why Java was invented...
           \_ The original poster's C++ program was too slow, so he's using
              obscure C++ features to make it run faster.  How would Java be
              better here?
           \_ In order to remove an optional feature?
              \_ Yup, that's why languages like C++ and Perl suck. I've
                 used both for years, and the things you can do with C++
                 are just fun fun fun. Next time you feel bored, insert
                 delete(this) in your code and see what happens.
                 \_ Don't knock what you don't know how to use.  I've been
                    in many situations where `delete this` came in quite
                    handy for memory management issues.  Instead of sitting
                    here complaining about how bad a language is because it
                    lets you do something you don't understand, take half a
                    second to realize that there's people in the world who
                    actually know how to program.
                 \_ Doctor, it hurts when I delete(this)...
                    \_ Son, you need to realloc(penis, 6 * INCHES);
2004/12/7-8 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages] UID:35200 Activity:low
12/7    Optimization time: gprof shows 310k calls to a certain constructor
        (a very simple, very important object that is often stack-allocated
        into large arrays- eg "MyObject msgs[1000];").  Rather than calling
        the constructor 1000 times, is there a way to have a special array ctor
        that's called (once) and zeroes out the array en masse?  TIA.
        \_ Geezus, why are you constructing 310k objects? Make a static array
           of objects at the beginning of runtime.
           \_ I am, when possible.  It's a realtime system (= no dynamic memory
              allocation) so e.g. several queue objects have to buffer
              about 15k messages statically.  The rest are open to optimization,
              but a specialized array constructor (if it exists) would be nice.
              (nb: by "nice" I mean "not at all critical")
              Oh, and if it helps for those in a similar situation: MyObject
              contains a couple small arrays; it's much faster to zero these out
              manually with a for loop than with memset(). -op
              \_ Man, I hate people like you. Why didn't you give the complete
                 environment information in the first place? What type of
                 RTS system are you using and in what form factor? How much
                 total RAM do you have and what form is it in? And why the hell
                 are you using an OO language for small RTS apps?
                 \_ Sorry, I was just curious if C++ had a specialized ctor for
                    objects created in an array; I didn't realize I was creating
                    a tone of urgency.  Anyway, system is not resource-
                    constrained at all (P3 in a VXI chassis, 512M ram, etc) &
                    I'm coming to the conclusion that I can't just define
                    MyObject::MyObject[] ().
                    \_ Yes you can, you can overload new[].
                       \_ Ok, this might be helpful; can you elaborate?  What
                          would the constructor declaration look like?
       \_ If you want the array zeroed out without any object construction
          occuring, there are a few things you can do:
          (1) Create a default constructor which doesn't do anything
          (2) Overload new[] as suggested above to accomplish this
          (3) Allocate the space for the array using malloc or calloc instead
              of new and then use placement new to do the construction.
              Specifically, placement new lets you construct an object into
              a memory location you have allocated yourself.  The benefit of
              this is that your program would only need to spend time
              constructing an object when you want to put it in the array
              instead of when you allocate the whole array.  -emin
2004/11/10-11 [Computer/SW/Languages/C_Cplusplus] UID:34810 Activity:low
11/10   In ISO C, since the type for difference between two pointers is
        ptrdiff_t, does that imply the correct type for array indices is
        ptrdiff_t?
        \_ The standard says only that the array index is of an integer type.
           \_ I see.  Thanks.
2024/12/25 [General] UID:1000 Activity:popular
12/25   

2004/11/9 [Recreation/House, Reference/BayArea, Computer/SW/Languages/C_Cplusplus] UID:34774 Activity:nil
11/09   I need to find a storage place in south bay for lots of books and also
        some furniture and electronics.  To save money, I prefer a non-A/C
        place.  Should I worry about moisture damange?  Does it matter
        if it is ground floor or up?  Thanks.
2004/11/5-7 [Computer/SW/Languages/C_Cplusplus] UID:34697 Activity:high
11/5    In C, why is the "offsetof" macro defined to be of type size_t but not
        ptrdiff_t?  Thx.
        \_ Probably because ptrdiff_t is signed and size_t isn't.
           \_ How does being signed make ptrdiff_t less portable?
              \_ Imagine a 16-bit C implementation, where int is 16 bits, long
                 is 32 bits, and the maximum object size is 64k - 1.  size_t
                 can be unsigned int, but ptrdiff_t has to be long; you save
                 time and memory by using size_t when possible.  --mconst
              \_ Who said anything about portability?  It looks like one of
                 those cases where since the value is always >= 0 the standards
                 guys use an unsigned type.
2004/11/4-5 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Misc] UID:34675 Activity:kinda low
11/4    I'm learning Fortran 90 for work, and it's suddenly very clear why
        C became so popular.
        \_ so, what's a good language for numerical stuff these days?
           \_ Sadly, the really isn't one.  Fortran 90 is still used, C++
              is used a lot as well.  Niether is really good for the task.
           \_ [Matlab] equivalence class if you don't care about speed :).
                -- ilyas
                \_  Jesus fucking christ.  I actually agree with ilyas on
                    something.  There must be something wrong with matlab
                    I have not noticed.
                    \_ Shut up Rob.
                       \_ Hi tom!
                          \_ uh, what?  -tom
                             \_ Oh eat it you bitch!  I've got the SHOOEEE!
2004/10/29-30 [Computer/SW/Languages/C_Cplusplus] UID:34449 Activity:very high
10/29   C++ is so freaking BROKEN.  Augh!
        \_ Just use C.
           \_ Would if I could.
        \_ No, you are.  C++ works just fine, and far better than C for many
           purposes.
           \_ C vs. C++.  FIGHT!!!
           \_ True, it's better than C for many purposes, but at the very
              least it has some serious lexing/syntax issues.
              \_ Most of the warts stem from backwards compatibility with C
                 (primarily integer promotion, operator precendence, etc.).
                 \_ Bull... Shit... Things which are broken in C++:
                    Confusing Scoping Operators
                    Confusing auto creation vs. explicit instantiation of objects.
                    Confusing auto creation vs. explicit instantiation of
                      objects.
                    Ability to overload things like new.
                    Ability to do crappy stuff like delete this.
                    Multiple Inheritance
                    Friends (god, wtf was Bjarne thinking?)
                    Sticking classes in .h files.
                    Templates (good idea, but crap implementation).
                    STL was too damn late in coming so nobody uses it.
                    Language is too frickin' big.
                    We should've adopted Objective C over C++. C++ is just
                    a dog of a language. Just take a look at MFC and its mess.
                    \_ cs61b got you down?  I've actually seen alot of the
                       stuff on your list used in VERY effective ways.  Most of
                       your complaints sound like the things newbies whine
                       about.  Train harder, grasshopper.
                    \_ A lot of the things you list are not broken.  Just
                       because something is confusing to _you_ does not make
                       it 'broken.'  Just because something is an advanced
                       feature for which you see no use (overloading new) does
                       not make it broken.  However, I will agree that C++ is
                       combining too many worlds in a poor and inelegant way.
                       Still, I have to respect it in that you CAN get work
                       done in it. -- ilyas
                       done in it.  We would not have been better off with
                       ObjC over C++, though ObjC is certainly a much
                       smaller language.  One reason is, ObjC uses essentially
                       the smalltalk object system, which is not suitable for
                       many systemy kinds of programming. -- ilyas
                       P.S.  My favorite MFC moment is seeing stuff like:
                       template <class T> class Foo : public T { ... }
                       \_ This is typically called a shim class.  And?
                          \_ There is no and.  I just find the idiom amusing.
                    \_ You learned Java before C++ right?  It's hard to move to
                       a real language after playing with toys for a while.
                       I've used all the above features well, and use STL
                       heavily.  (You didn't even mention streams.  Amateur.)
                    \_ Actually, I was thinking more of obvious stuff like
                       the << and >> template problems, and the fact that
                       :: is both the namespace separator and the name for
                       the "global namespace." (Which becomes a problem
                       when the C++ lexer throws away whitespace...) -op
                       \_ How is :: the "name" for the global namespace?
                          If it were, then you'd access globals by ::::foo,
                          yes?  Isn't the "name" for the global namespace
                          epsilon (nothing)?  :: is always a namespace
                          separator.
                          \_ Sorry I didn't state it in explicit theory
                             terms, but it amounts to the same thing.  If
                             you want to specify the global namespace, you
                             begin the identifier name with ::.  ie
                             ::foo:bar.  I was just using the same
                                  \_ A single colon is not a namespace
                                     separator.  Did you mean ::foo::bar?  Are
                                     you sure you're programming in C++?
                             terminology used in a C++ book I read a
                             while ago.  It maybe have been Bjarne, but I
                             can't remember exactly.
                             \_ Errr, read the post above you again.  pp is
                                exactly right. -- ilyas
                                \_ Errr.. read my post again, I agreed
                                   with him.
                             \_ Right.  This works just like Unix pathnames --
                                foo/bar is a relative path, and /foo/bar is an
                                absolute path.  What problems does it create?
                                Yes, >> in templates is stupid.
                                \_ I just had this experiance, if you have
                                   2 identifiers in a row, ie "id1 id2",
                                   and you try to force the global id2,
                                   C++ throws out the white space, so
                                   instead of having two identifiers, you
                                   get 1 big identifier "id1::id2", which,
                                   of course, it can't find.
                                   \_ That doesn't even make sense.  White
                                      space separates tokens.  I don't think
                                      you know what you're talking about.
                                      \_ Maybe it's only true in gcc 3.4,
                                         go ahead and try it.
                                         \_ I don't have access to gcc 3.4 (nor
                                            do I want it).  That sounds like a
                                            bug in a compiler, not a language
                                            flaw.
                                         \_ It doesn't make sense, and you
                                            haven't provided enough instruction
                                            about how to reproduce it.  What
                                            do you mean "have two identifiers"
                                            in a row?  When would that be legal
                                            at all?  In what context?  How
                                            about some real code?
                                            \_ If you like:
                                #include <iostream>

                                class B { };

                                class A {
                                 public:
                                  B foo();
                                };

                                B ::A::foo() {
                                  std::cout << "Hello" << std::endl;
                                  return B();
                                }

                                int main() {

                                  A a;
                                  a.foo();
                                  return 0;
                                }

        fails with this error:
        test.cc:11: error: `class B::A' has not been declared
        test.cc:11: error: ISO C++ forbids declaration of `foo' with no type
                        \_ But you shouldn't need to have (or be expected to
                           have) the global namespace qualifier in A::foo's
                           definition anyway.  How about an example where it's
                           actually a problem?  The scoping operator (::) does
                           need to discount whitespace, because otherwise you
                           wouldn't be able to break apart really::really::
                           long::lines.
                           \_ The case where I ran into this as a "real
                              problem" spanned multiple files and
                              thousands of lines of code.  So I contrived
                              an example.  I'm pretty sure that's a normal
                              thing to do.
                              \_ Explain how.  C++ doesn't allow nested
                                 functions, so you either define functions
                                 in global scope or within a namespace.
                                 If you're already in global scope, you
                                 don't need the leading ::.  If you're not
                                 in global scope, why are you defining a
                                 function in one namespace from within another?
                                 \_ And inablilty to explicitly declare a
                                    function in global scope doesn't
                                    strike you as a little wierd?  Even if
                                    it is usually unnecessary?  I never
                                    said I couldn't do something else.  I
                                    did something else and it worked, that
                                    doesn't mean this isn't bad design.
                                    \_ And it doesn't strike you as weird that
                                       you want to do something like:

                                        class A {
                                          void f();
                                        };

                                        namespace foo {
                                           void ::A::f() { }
                                        }

                                       ?  I mean, really.  Even if you could
                                       do it, you're just making your own
                                       code more unmaintainable by defining
                                       functions where they don't belong.
                                    \_ I think you must be using non-C++
                                       concepts and trying to for them into
                                       C++.  By the same token, you can't take
                                       English idioms and translate them word-
                                       for-word into Spanish.
                                       \_ Most of my work is research
                                          outside the concepts of any
                                          language.  SO yeah.
                                    \_ No, it doesn't seem weird.  Most
                                       lexically-scoped languages allow things
                                       to be declared only in the current
                                       scope.
                                       \_ Maybe so, but in C++ you have to
                                          define methods explicity in a
                                          namespace, but you can't
                                          expicitly declare the namespace.
                                          Perhaps you could argue that
                                          it's just an unfortuate mix of
                                          C++ features, but that's bad
                                          design isn't it?
                                          \_ What do you mean?  You don't
                                             have to define methods explicitly
                                             in a namespace (you put them
                                             within a "namespace ns { ... }"
                                             block).  And how is that not
                                             explicitly declaring the namespace
                                             itself?  And no, it's not a bad
                                             design.  Have you not noticed that
                                             you alone seem to be the only
                                             person who has any issues with
                                             this?  Sane programs written
                                             properly won't have these issues.
                    \_ Let's all switch to http://digitalmars.com/d
                       \_ BCPL is the STANDARD!
2004/10/25-26 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Security] UID:34329 Activity:low
10/25   I have a problem in C++.  I have a bunch of autogenerated classes
        that I need to be able to convert between.  I made a templeted
        cast function in a common header file, but it needs to access a
        protected function in the generated classes.  Is there any way to
        make a templeted friend function shared between all those
        auto-generated classes?  I tried, but I got an error that the
        function hadn't been defined.  From the first auto-gen'd class.
        \_ My head hurts.
           \_ Hahahaha, you made my day!
        \_ is there some reason you can't make better use of polymorphism
           and virtual functions instead of all this conversion crap?
           \_ Yes.  http://www.llnl.gov/CASC/components/babel.html
              \_ Could you explain the relevance of this URL to why
                 you can make better use of polymorphism and v-fncs? -npp
        \_ Any reason not to use a public accessor?
           \_ This is what I've done for now, but I would prefer not to.
              \_ Thing is, friend templates are a mess with current compiler
                 implementations.  I'd hesitate to depend on that feature if
                 you want any kind of portability.  Another possibility would
                 be a template member which does the conversion for you from/to
                 an intermediate type.
        \_ are you allowed to modify the autogened files at all? you could
           convert the private members to protected. then use explicit
           naming to access the protected members from your casting function.
           \_ I'm not sure what you mean by this.  Can I access protected
              data with a non-member function through some kind of
              explicit naming?
2004/10/24-25 [Computer/SW/Languages/C_Cplusplus] UID:34317 Activity:nil
10/23   What's the difference between a mode A, mode C, and mode S
        transponder? Mode A/C is having altitude/no altitude encoding
        right? What about mode S?               -squawk ident guy
        \_ What the hell are you talking about?  -half of soda
2004/9/28-29 [Computer/SW/Languages/C_Cplusplus] UID:33807 Activity:nil
9/28    Does anybody use this sort of style for for loops in C:
        Foo *ptr;
        int i;
        for (i=0; i < arraySize; ptr = &array[i++])
        ?  Does it work well?
        \_ Uh, what's the point?  If you're going to go through the trouble
           of having an explicit index and doing the add-and-dereference
           thing (which a compiler should optimize away anyway), why not use
           array[i] instead of ptr?
        \_ Aside from the point above, looks like you're not initializing ptr
           on the first iteration.
2004/9/27 [Computer/SW/Languages/C_Cplusplus] UID:33781 Activity:high
9/27    How are functions like C's printf made?  It can take 1-N arguments and
        the 2-N arguments can be of almost any type.  How do you write a
        function like that?  Surely printf wouldn't work with 500 arguments?
        \_ probably would, depends on how much stack you have.  See <stdarg.h>
        \_ man stdarg
        \_ Has to do with the ... function argument notation.  Check your
           K&R.
2004/9/23 [Computer/SW/Languages/C_Cplusplus] UID:33716 Activity:high
9/23    Is the a C++ equivelent to the C realloc function?
        \_ realloc(). But seriously, maybe you want an STL container
           that automatically grows.
           \_ Not in this case.  I just need to grow a char array
              automatically myself.   (For speed reasons) Really, It's a
              very isolated place in the code, and I'll probably just end
              up switching the news and deletes to mallocs and frees, and
              therefore use realloc when I need to grow the array.  But I
              was curious if there was an equivelent that would work with
              new and delete.
              \_ No, there is no equivalent for new/delete.  You probably
                 should avoid using arrays and new/delete directly anyway.
                 It's hard to make it exception-safe.  Either use an STL
                 container (e.g. vector or string; shrinking a vector
                 doesn't free memory to the system though) or write your
                 own container that uses malloc/free/realloc.
              \_ If you need to do this for performance then you should avoid
                 new/delete, and especially STL containers.  STL containers
                 require new elements to be default initialized, etc.  I wrote
                 my own "pod_vector" for POD types that uses malloc/realloc
                 etc. for high performance.  If you do this, it's important to
                 have unit tests.
2004/9/20-21 [Computer/SW/Languages/C_Cplusplus, Uncategorized/German] UID:33644 Activity:moderate
9/20    C question.  If I have
                #define NAME    FOO
        is there any way to use NAME to create a string "FOO"?  Thanks.
        \_ Do you mean #define NAME "FOO" ?  Or do you want to declare a
           variable?  Can you show NAME used in a sample line of code?
           \_ What I want is something like, say,
                strncpy(myArray, $$NAME, sizeof myArray);
              and I want $$NAME to compile to "FOO".
              \_ What's wrong with a const char* string? You want
                 #define NAME "FOO".
                 \_ Because the #define is at somewhere else that I can't
                    change.
        \_ Short answer yes, but it involves so much hackery that it's not
           worth it.  The link below used to explain how but it's 404'd now,
           maybe you can google cache for the original.
http://userpage.fu-berlin.de/~ram/pub/pub_isews26/c_preprocessor_applications_en
           http://tinyurl.com/6xmuz
           \_ ow ow ow! (the relevant code)
              //enumstring.c
              #include <stdio.h>
              #define NAMES C(RED)C(GREEN)C(BLUE)
              #define C(x) x,
              enum color { NAMES TOP };
              #undef C
              #define C(x) #x,
              const char * const color_name[] = { NAMES };
              int main( void )
              { printf( "The color is %s.\n", color_name[ RED ]);
                printf( "There are %d colors.\n", TOP ); }

              (stdout)
              The color is RED.
              There are 3 colors.
        \_ Am I missing something? What's wrong with using #NAME to stringify?
           e.g. #define str(x) #x
           \_ Then str(NAME) gives me "NAME", but I want "FOO".
2004/9/20 [Computer/SW/Languages/C_Cplusplus] UID:33628 Activity:moderate
9/20    What's the best way to read in an entire file into a string in C++?
        I know it's a fairly small file, so size isn't so much of an issue.
        I'm thinking of doing something like

        ifstream ifs("foo"); ifs.unsetf(ios::skipws);
        istream_iterator<char> begin(ifs);
        istream_iterator<char> end;
        string contents(begin, end);

        I should check !ifs first to see if the file opened ok, but what if
        the istream_iterator fails to read something instead, and what
        kind of performance should I expect to get? It looks pretty clean,
        but not very efficient. Thanks.
        \_ Without knowing your design constraints, there is not "best" answer.
        \_ Without knowing your design constraints, there is no "best" answer.
           Note that earlier versions of the C++ lib don't have std::string
           expand geometrically like vector, so you don't have guaranteed
           amortized constant time growth.
           \_ I'm working on fairly modern systems. This isn't really
              performance critical, but just out of curiosity, I'd like the
              fastest solution that's still relatively clean. Thanks.
2004/9/16-17 [Computer/SW/Languages/C_Cplusplus] UID:33567 Activity:nil
9/16    In emacs how do you say "I want to kill all of the buffers that end
        with hello.log", in cases where you have multiple */hello.log files?
        \_ Here's a way with keyboard macros that takes no thought:
           C-x C-b C-x C-o C-x ( C-s .log RET d C-x ) C-u 100 C-x e x
        \_ Here's a way with lisp programming which forced me to whip out
           some documentation:
              (defun remove-if-log (buf)
                (if (string-match "\\.log$" (buffer-name buf))
                    (kill-buffer buf)))
              (defun kill-log-bufs ()
                (mapcar (function remove-if-log) (buffer-list)))
2004/9/7-8 [Computer/SW/Languages/C_Cplusplus, Computer/Theory] UID:33385 Activity:kinda low
9/7     what is the answer to a negative number modulo some positive
        number? is it that same negative number?
        \_ -1 % 4 = 3, -2 % 4 = 2, -5 % 4 = 3.  I think.
           \_ That's not what bc or mscalc.exe say, but MS Excel agrees w/you!
        \_ Ask Dr. Math: http://mathforum.org/library/drmath/view/52343.html
        \_ In mathematics, a mod b where b is positive always returns positive.
           In C and C++, the '%' operator is pronounced 'remainder' and the
           results of a % b if a is negative is implementation defined.
        \_ Also Wikipedia:  http://en.wikipedia.org/wiki/Modular_arithmetic
2004/8/30-31 [Computer/SW/Languages/C_Cplusplus] UID:33228 Activity:high
8/30    Ok this is pretty basic but... is there a way to "escape" text to
        avoid it being substituted by C preprocessor macro expansion?
        \_ Wouldn't that functionality make C preprocessing as powerful as
           lisp's quasiquote/escape? -- ilyas
           \_ Squish!  Isn't it illegal to talk about lisp on the motd?!
        \_ In general no.
        \_ What are you trying to accomplish?  -- misha.
           \_ Oh, nothing interesting. We use CPP to preprocess some in-house
              language files. Normally CPP doesn't expand macros inside strings
              I think but it seems to happen here. Anyway it's not important.
              I'll go ask the dude that wrote the thing what it's doing.
2004/8/18-19 [Computer/SW/Languages/C_Cplusplus] UID:32995 Activity:very high
8/18    Doesn't math.h define min() and max() functions?  What should I include
        to get them?  I'd rather not do the (a < b) ? a : b thing.  Thx
        \_ No.  Many programmers define it as a new macro.  Don't know what
           gcc people do, offhand.
        \_ OS X has fmin(3)/fmax(3) which conform to ISO/IEC 9899:1999(E).
           Linux might have these too.
        \_ If you do the macro, do it right at least:
           #define min(a,b) (((a) < (b)) ? (a) : (b))
           Keep in mind that evaluates an expression twice.  If this is C++,
           <algorithm> defines std::min() and std::max().
            defines std::min() and std::max().
           \_ ... and, if you do define them as macros, name them as MIN and
              MAX.  Don't make things with macro semantics look like normal
              functions.  Anyway, to the OP, what would you have math.h
              do?  C doesn't offer templates or function overloading, so
              would you have it define separate min/max functions for the
              various numeric types (and possibly combinations of types),
              using different function names for each case? --jameslin
              \_ Sidenote: About macro names.  Why are putc() and putchar()
                 defined with lower-cases?
2004/8/10-11 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Compilers] UID:32805 Activity:high
8/10    C question.  Is there anything wrong with the following?

        const my_struct_t **pp;
        pp = malloc(sizeof(my_struct_t *));
        pp = realloc(pp, sizeof (my_struct_t *) * 2);

        "gcc -Wall" doesn't complain.  But the M$ compiler (cl.exe) complains
        about the realloc line:

        t3.c(12) : warning C4090: 'function' : different 'const' qualifiers
        t3.c(12) : warning C4022: 'realloc' : pointer mismatch for actual
        parameter 1

        Thanks in advance.
        \_ Your code is correct.  The warnings above are both wrong, and in
           fact the same compiler recognizes the code as safe in C++ mode
           (which is stricter about const).  --mconst
        \_ I'd ask why GCC isn't complaining.  Consts shouldn't change.
           It might be that because there's nothing between the malloc and
           the realloc, GCC is noticing that the value of pp does not actually
           changem while MS sees you are writing to a const and bitches.
           \_ But what I'm trying to realloc is an array of variable pointers
              to constant structures.  The array elements (pointers to constant
              structures, const my_struct_t *) are not consts and do change.
              It's just that the structrues that the array elements point to
              (const my_struct_t) don't change.  I think it's just stupidity on
              M$'s part, but I just want to make sure.
              \_ YMWTS http://www.parashift.com/c++-faq-lite/const-correctness.html
        \_ You sure you're not compiling in MS as a cpp file?
           \_ It works as a CPP file -- see above.  --mconst
           \_ My file is a .c, and I compile like "cl t.c" with no options.
              I tried both version 12 and version 13 and they gave the same
              warning.
        \_ Where is the 'function' name declared?
        \_ BTW, pp = realloc(pp, ...) is a bad idea.  If realloc fails, you've
           just clobbered your old copy of pp and no longer can free it.
           --jameslin
           \_ Yeah I know.  The above was just to illustrate the type checking
              warning.  But thanks.
        \_ Does it still complain if you do something like:
           typedef const struct foo *pfoo;
           ...
           pfoo *p;
           ...
2004/8/5-8 [Academia/Berkeley/CSUA, Industry/Jobs, Computer/SW/Languages/C_Cplusplus] UID:32725 Activity:nil 50%like:36020
8/5     Another Mountain View job.  Senior C++ developer.
        /csua/pub/jobs/coral8
     _________________________________________________________________
2004/8/4 [Computer/SW/Languages/C_Cplusplus] UID:32675 Activity:nil
8/4     A little humor for C programmers in the audience:
        http://csua.org/u/8g8
2004/7/29-30 [Computer/SW/Languages/C_Cplusplus] UID:32574 Activity:moderate
7/29    How do I describe scope in C?  Is it outer/inner scope?  Higher/lower
        scope?  Parent/child scope?  I forgot.  Thanks.
        \_ "Trivial C Question Troll", I love you!
        \_ you're thinking in OO terms. C has "local" and "global" scope.
           \_ C99 has more than two levels of scope.  For instance, each for
              loop has its own scope.  Also, gcc lets you define functions
              inside other functions, as a (non-standard) extension. -- ilyas
              \_ Hasn't it always been the case that each pair of {} has its
                 own scope, even before C99?
                 \_ Yeah you are right. -- ilyas
                 \_ Yes.
           \_ I was going to say that, but was afraid the OP might be more leet
              than me.
           \_ What I'm thinking is something like:
                void foo(void) {
                  ... code 1 ...
                  {
                    int i;
                    ... code 2 ...
                    {
                      ... code 3 ...
                    }
                  }
                }
              So "i" is defined in code 2 and 3, but not in code 1.  How do I
              describe this?
              \_ The scope in C is really simple, it's based on block scoping
                 where the blocks are defined by curly braces.
                 If it's at the beginning of a curly, it's scope is anything
                 between the curlys, ergo the term "block." Some people call
                 it "area scoping" defined by the "area" of code defined by
                 the braces. Some others call it "brace" scoping.
              \_ If code 3 is not a function called from code 2, you just
                 answered your own question.
                 \_ You can't define a function inside another function in C.
                    \_ Duh.  But code 3 could be a function call that needs 'i'
                    \_ Huh?  I thought the op is talking about nested inner
                       blocks.  Who said anything about functions?
              \_ i is in scope in code 2 and 3, but not in scope in code 1.
        \_ Although this isn't the example you are giving are you thinking
           about lexical vs dynamic scope?
           \_ The original question is just that which pair of adjectives to
              use to describe the scopes in the same file.
              \_ Nested.  Inner.  Take your pick.
2004/7/27-28 [Computer/SW/Languages/C_Cplusplus, Computer/SW/WWW/Browsers] UID:32514 Activity:nil
7/27    Does the Mozilla mail client have any kind of macro language?
        Currently I use emacs for mail since I really like being able
        to customize it and write macros.  Thanks.
        \_ Yeah, combining macros with email is great.
        \_ OUTLOOK IS THE STANDARD!  USE VIRUS!
2004/7/15-16 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Editors/Emacs] UID:32311 Activity:low
7/15    In emacs20, how do I set indent-tabs-mode to nil using ~/.emacs such
        that emacs will use spaces instead of tabs to indent in all my C files?
        I tried "(setq indent-tabs-mode nil)", but the value is still t.
        Thanks.
        --- yuen
        \_ use setq-default, or look up hooks in the emacs manual.
           \_ I see.  Now c-mode-common-hook does the trick.  Thx.  -- yuen
2004/7/13-14 [Computer/SW/Languages/C_Cplusplus] UID:32265 Activity:high
7/12    Someone please explain the following?
        ((size_t )& ((SomeVar *)0)->Field);
        \_ It's a hideous abuse of C++ syntax and results in undefined
           behavior.  It appears to be an attempt to find out the offset of the
           member "Field" in the class/struct type SomeVar.  Ow, ow ow.
           \_ This is actually not undefined, in C or C++.  It is hideous,
              though; it would be nicer to #include <stddef.h> and just use
              though; it would be nicer to #include  and just use
              offsetof(SomeVar, Field).  In C++, you might also be able to
              use a pointer-to-member (&SomeVar::Field), depending on what
              you're trying to do.  --mconst
              \_ You're saying that dereferencing a null pointer is not
                 undefined? -emarkp
                 \_ Right.  In C99, you're allowed to dereference a null
                    pointer as long as all you do is take the address of
                    it afterwards; see 6.5.3.2p3.  In C++, it's not very
                    well stated in the standard, but the current view of
                    the committee is that you're allowed to do anything
                    with a dereferenced null pointer as long as you don't
                    trigger lvalue-to-rvalue conversion or try to write
                    to the memory; see http://csua.org/u/86c  --mconst
                    \_ Fascinating.  I usually follow Herb Sutter's articles to
                       keep me up-to-date.  Thanks for the info.  I just wish
                       they'd add a typeof operator and ditch the nonsensical
                       syntax of calling a static member function though an
                       instance (requiring T::func() instead of allowing T x;
                       x.func(); ). -emarkp
                    \_ Although 6.5.3.2 states that &*E is legal, it does not
                       address the issue in the original question, which
                       involves an additional structure member access.  I
                       believe that it is implementation-dependent.  It is
                       the compiler vendor's responsibility to provide an
                       offsetof macro in stddef.h that works with their own
                       implementation, but it need not be portable. --jameslin
                       \_ You're right, I take it back -- the original
                          statement is actually undefined in C99.  It works
                          for arrays, but not structs.  (It is still valid
                          C++, although it's not guaranteed to produce the
                          value you want.)  --mconst
        \_ So shouldn't your "SomeVar" be "SomeType" for clarity? That
           confused me for a bit.
2004/7/12-13 [Computer/SW/Languages/C_Cplusplus] UID:32241 Activity:very high
7/12    In C, what should be the data type for array indices?  I usually just
        use "int".  Thx.
        \_ YES!  The 'trivial C question troll' is back!  I love you, man!
        \_ int is fine, but I often find myself using unsigned int, especially
           in for loops where I compare unsigned int i against some maximum-
           value variable that is also unsigned int.
        \_ It's an integer type.  a[i] is the same as *(a + i).  Can be signed,
           can be negative.  Why do you care?
           \_ I'm just wonder if the K&R spec says anything about it.  I don't
              have the spec here.
        \_ size_t
           \_ Are you sure?  It's not, say, ptrdiff_t?  Isn't a[-1] legal?
                \_ You can use ssize_t if you like, I personally prefer
                   size_t since stuff like a[-1] can often lead to bugs
                   if you aren't completely sure what a points to.
                   \_ The original question wasn't what type /should/ be
                      used; it was what it *is*.  Section 6.5.2.1 of the
                      C99 standard says merely, "integer type" and (as I
                      said before) that a[i] is identical to *(a + i) (from
                      which it should be obvious that the index is an integer
                      type).
        \_ To settle this question once and for all, just look at the C
           standard? It says the subscript shall be an integral type.
           Integral type is defined as char, an unsigned or signed integer
           type, or an enumerated type. A signed integer type is signed
           char, short int, int, or long int, and unsigned integer type is
           the corresponding unsigned type. Clear enough?
           \_ You could have just said:  The C standard (post URL) says the
              index can be an integral type (signed/unsigned short/long
              char, int, enum), and negative values are permitted.
              \_ There is no URL for the C standard. Or not a legal one,
                 anyway. There are various draft standards, though.
           \_ what about long long?
              \_ above is for C90. C99 draft standard has somewhat different
                 verbiage, but the spirit is the same. basically all integer
                 types can be subscripts.
2004/7/2-3 [Computer/SW/Languages/C_Cplusplus] UID:31149 Activity:moderate
7/2     Is this valid C++ code?  It works for gcc but in VxWorks the array
        is initialized to { 0, 0 }.  Just out of curiosity/bitterness.  tia.
        #define IN_Q 0
        #define OUT_Q 1
        int foo () {
          int queueTypes[] = { IN_Q, OUT_Q };
          ...
        }
        \_ Yes. Better yet, use const ints for IN_Q and OUT_Q if it's C++.
        \_ Yes, perfectly legal and pretty basic.  Something that can't handle
           that is pretty broken.  You sure there's not more to it?
2004/6/29-30 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Perl] UID:31060 Activity:high
6/29    I can't remember a bit of C syntax.  I have funtion foo that
        returns a value that I need to put in a variable.  If that value
        is not Null, I want to take some action.  Will this work?
        int bar = 0;
        if(bar = foo())
          do something;
        \_ Someone should save this for the Classic Trolls Of All Time Hall
           Of Fame.  I wish I had thought of something so simple as asking
           an arcane C syntax question.  --lesser troll than op
           \_ Maybe you should try an obscure Perl question.
        \_ How about:
           if(foo()) {something;}
        \_ foo() can return NULL, so it's returning a pointer.  Therefore
           bar should be a pointer.  Probably it's a char* pointer.  So:
           char* bar = NULL;
           bar = foo();
           if (bar != NULL) { // Do something. }
           , or, if (!bar) { // Do something.} (but I like the previous one)
           \_ The null pointer is just an integer equal to zero.  If the
              declaration of foo is 'void foo()' then 'if(foo())' will fail.
              The NULL pointer evaluates to false.
              \_ op said he wanted to store the value of foo() in a variable,
                 and also wants to check if it is NULL.  (This is common for
                 text-parsing functions.)  Hence the code.
              \_ 1. if the declaration of foo is "void foo()", it can't even
                 return anything, and "if(foo())" won't even compile.  What are
                 you trying to say?
                 2. There is nothing in the C specification that says NULL is
                 necessarily 0.  Its value is implementation dependent,
                 although in almost all implementations it's 0.
              \_ Not exactly.  The preprocessor symbol NULL is guaranteed to
                 be 0, but it's not necessarily an integer type (it may be
                 defined to be (void*) 0).  NULL is not the same as the "null
                 pointer"; the compiler transforms 0 in pointer contexts to
                 the appropriate null pointer, which may not necessarily be
                 all-bits-zero. --jameslin
        \_ The answer is yes.  The syntax is:
           if (bar = foo())
            |    \_ Assign 'bar' to be the return value of foo().
            |
            \_ The value passed to 'if' is the result of the assignment, which
               is the value of 'bar'.  Any non-zero integral value will
               evaluate as true.
        \_ "if (bar = foo())" will work, but the compile will probably try to
           be nice and warn you that you might have mistyped "=" when
           you really wanted "==".  To avoid such a warning, you can do
           "if ((bar = foo()) != NULL)".  With compilers these days, it'll be
           optimized the same way as "if (bar = foo())" anyway if the value of
           NULL is 0.
           \_ And this compiler should be promptly thrown in the trash.  In
              over 10 years of C/C++ development, I've only been bitten by this
              once or twice.  Having to munge my code to avoid spurious
              warnings only helps newbies who should quickly exit the rank of
              newbie anyway.
                 \_ Isn't this based on the assumption that NULL == 0 or
                    some equiv. There is nothing in the standard (AFAIK)
                    that requires this.
                    \_ No.  When a pointer converts to an int, it must convert
                       to 0 if it is NULL, regardless of the actual bit pattern
                       of the pointer.
                        \_ ic. tnx.
              \_ Chill down.  The compiler gives a warning, not an error.
                 \_ Spurious warnings make it difficult to find real problems.
                    Many software shops have a rule of compiling with no
                    warnings and no errors, so warnings are a problem anyway.
                    \_ Having to munge your code for spurious warnings is
                       a bad thing.  However, I challenge your determination
                       that this particular one is spurious.  I would want
                       all my developers to NEVER have an "if (bar = foo())"
                       statement.  That's IMO, anyway.  They can still do
                       it if they want; I wouldn't complain too much if
                       following the rule affected their productivity, what
                       with good people being hard to find.
                       \_ How many more coding guidelines do you want checked
                          in your compiler?  Check it in lint instead.  Why
                          should I have to avoid legal code because *your*
                          software shop doesn't like that?  It's a common
                          idiom, and it takes all of 5 seconds to learn it.
                          \_ I don't think you really read what I wrote.
                             I believe if you got into a meeting with the
                             top 5 coders in your organization, they would
                             agree "if (bar = foo())" is bad form, but they
                             wouldn't bash it over your head, which is what
                             I've been saying.  (Of course you can use whatever
                             you like if you're not working with other
                             programmers.)
                             \_ I did read what you read.  Your complaint is
                                one of style, which is not what a compiler
                                should check--or at least the complier should
                                have a way to turn off all stylistic warnings.
                                \_ I agree with you that the user should be
                                   able to turn off "stylistic warnings".
              \_ You want to throw gcc in the trash?
              \_ I was grateful of compiler warnings when I had a very sloppy
                 programmer working on my team.  Eventually he was let go after
                 one year.
                 \_ Which is the right thing to do with sloppy programmers:
                    teach them or fire them.
2004/6/29-30 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Unix] UID:31057 Activity:kinda low
6/29    Is there a C function to get the name of an opened file from its file
        pointer (FILE*)?  Thanks.
        \_ I don't know of one.  What would happen if there are multiple
           ways of describing the file? (Symbolic links and the like)
        \_ the best you can do is use fileno() to get the file descriptor
           number and then pass that to fstat() to get the inode and
           filesystem of the underlying file.  To get an actual path name
           from there is difficult, as you could have any number of hard links
           pointing to the inode, and it is even possible for there to be
           NO links and there is in fact no file name associated with the
           file's inode.(i.e. it was 'deleted' after it was opened).
           If you *really* want to know you could run a search through the
           filesystem for matching inode numbers. -EricM
2004/6/18 [Computer/SW/Languages/C_Cplusplus] UID:30883 Activity:high
6/17    Someone asked me to write them a letter of recommendation. Is there a
        recommended cookie cutter formula like
        1. They did A, B, C. 2. They excelled at D. 3. They left for reason E?
        I've already asked the person to give me a list of the accomplishments
        that he would like me to focus on.
        \_ Academic or industry?  For managerial position or grunt work?  It
           matters.
           \_ industry grunt work.
              \_ Then you want to write something about what a good employee
                 they are, good team player, always on time, good contributor,
                 and always rose above the call of duty and how much you would
                 like to work with the person again.  Yes, lie if you like the
                 person and want them to get the job.
        \_ Google "writing letter of recommendation."  There are lots of
           resources out there for you.
2004/6/10-11 [Computer/SW/Languages/C_Cplusplus] UID:30732 Activity:very high
6/10    Hi, what is "volatile function" in C (or is it C++)?  Thanks.
        \_ They're used when writing vaporware.
        \_ I imagine it's a method that operates on a volatile object (?)
           \_ Uhm, no... that wouldn't make much sense, now, would it?
              I've never used or see someone use "volatile" in all the
              years that I've been coding C (it's been 15+ years now).
              According to K&R the volatile modifier is used only
              variables that supposedly could be modified outside of
              the executing program. In the years since the original
              K&R during ANSI meetings there has been some debate over
              what "volatile" actually means and there hasn't been
              a satisfactory answer. I've never heard of anyone using
              "volatile" on declaring a function, I'm not even sure
              if that would pass the compiler...
              -williamc
              \_ Wow, way to look like a fucking dumbass again. "Just
                 because I've never seen volatile used means it, like,
                 doesn't make sense, or something!" Here's a snippet
                 from the C++ standard:
                 "[Note: volatile is a hint to the implementation to
                  avoid aggressive optimization involving the object
                  because the value of the object might be changed by
                  means undetectable by an implementation... In general,
                  the semantics of volatile are intended to be the same
                  in C++ as they are in C."
                 And in C, the volatile type specifier generally denotes
                 something like a memory-mapped IO address, so it's not
                 some totally abstract theoretical thing.
                        \_ Or a variable modified by a signal handler.
        \_ Google says that they are functions that can return control
           to some point other than where they were called from.
           \_ Uhm, that would be highly problematic.... -williamc
              \_ Uhm, you are an idiot.  This is about as problematic as
                 exceptions (that's exactly what they are designed to do).
                 Now I am sure volatile isn't implementing exceptions in C,
                 but your comment's ignorant regardless.
                 \_ Actually, it would be highly problematic in a C program,
                    because C doesn't implement exception handling.
                    It's apparent that YOU have never done any C
                    programming (no, this is not Java, and C++ exception
                    handling is still pretty broken). In addition,
                    you appear to fail to understand how exception
                    handling is implemented in general. -williamc
                    \_ Ok, let me try small words.  Poster: "functions that
                       can return control to some point other than where
                       they were called from."  You: "That [returning control
                       in this way] would be highly problematic."  Except
                       this is NOT highly problematic because that's exactly
                       what exceptions do.  You are a moron.
                       \_ It is nice to see people get hot and bothered and
                          make fools out of themselves by flaming on a topic
                          other than politics. Sir, I salute you for caring
                          so much about typecast functions.
                          \_ (Why) I oughta (knock) your block++ off;{!!;}
                    \_ You've never heard of setjmp and longjmp?
                 \_ youse guys are all cracka's!
                 \_ have any of you ever kissed a girl?!?
2004/6/6 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Compilers] UID:30635 Activity:nil
6/5     How does typedef get compiled into machine code?
        \_ what the hell are you talking about?  C?  It doesn't.  It's merely
           a type alias.  C compilers don't even do strict type-checking
           against typedefs; what makes you think it gets to the machine code
           level?
        \_ It doesn't get that far.  The answer to your question is closer
           to "How do ints, floats, structs, etc. get compiled into machine
           code?"
2004/6/3 [Health, Computer/SW/Languages/C_Cplusplus] UID:30560 Activity:moderate
6/3     Ok, who wants to share my recursion theory pain?  I just spent a really
        long time on a problem, and I want to make some volunteer suffer like
        I did.  If there's any interest, I ll post the problem. -- ilyas
        \_ Hah!  You want us to do your homework, huh?  The problem is
           trivial.  Check the man pages or look it up on Sun's website.
           \_ It's true that this is my homework, but I did make sure to do
              it first, before posting. -- ilyas
              \_ The answer must be in the man pages somewhere.
        \_ go ahead, i'm game
           \_ seconded
              \_ Ok.  For the purposes of this problem, we are dealing with
                 functions which accept a set of bitstrings as input, and
                 output bitstrings.  The problem is to construct two
                 (computable) functions f and g with the following properties:
                 (a) f and g take two arguments each
                 (b) for any two inputs, f returns a turing machine (TM)
                     where the language it accepts is decidable and disjoint
                     from the language accepted by a TM returned by g.
                     (g must also return a decidable TM).
                 (c) if f is given as input any two TMs (in your favorite
                     bitstring encoding) that accept complementary languages,
                     f returns an encoding for a TM which accepts the same
                     language as argument 1, and if g is given same, it
                     returns an encoding for a TM which accepts the same
                     language as argument 2.
                 Note: if f or g return a 'malformed' bitstring, which does
                 not code a TM, the accepted language is considered to be
                 empty (hence decidable).  Note 2: all finite sets are
                 decidable.  This problem is very hard.  I posted it
                 because I am a sadist. -- ilyas
                 \_ My guess is that you first make f do something
                    reasonable.  Then you make g have a copy of f inside
                    it so that g can do the opposite.  You said that the
                    problem was very hard, though, so perhaps this
                    strategy runs into decidability problems.
                    \_ Sure, this works fine.  You do have to figure out how
                       to make f do something reasonable, though.  --mconst
2004/6/2-3 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Java] UID:30552 Activity:high
6/2     How do I pass in a PrintWriter object and get back StringBuffer?
        I'd like to pass in an argument of type PrintWriter and have the
        output save to my StringBuffer (instead of System.out/err). Thanks.
        \_ Dude, figure this shit out yourself.  This is either homework or
           work, and the question isn't complicated either way.
           \_ I was just about to provide code samples, but I think you're
              right.  Teach 'em to fish and all that...
        \_ Scan through the javadoc for the java.io package
        \_ Damn... what would they be asking if classes were still in C or,
           god forbid, vax assembly?  I thought java was supposed to make it
           so easy even people like this can write it?
           \_ If you ask me, Java got rid of pointers and the associated
              memory bashing, and the library is a lot bigger (hard to
              remember the function names).  Of course, you also have C++,
              which combines the worst of both worlds. ;-)
2004/5/20-21 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/OCAML] UID:30334 Activity:insanely high
5/20    I have seen some ocaml comments on the motd.  What about Haskell?
        Is it better/worse/about the same?  I know it is supposed to "pure"
        but don't know what this translates to in reality.
        \_ Haskell is the only language I want to know something about, yet
           know almost nothing about.  I know it's not speedy, unlike ocaml,
           but has lots of clean ideas, and you can write really short code in
           it.  Haskell is a 'pure functional language' in that it allows no
           sideeffects.
           Haskell programmers use something called 'monadic programming' to
           get around this (say when doing IO).  Another way out is to use
           something called 'uniqueness typing' which is what Clean does.
           Personally I think insisting on a pure functional language is silly.
             -- ilyas
           \_ What value are these languages outside of theory and academia?
              \_ Troll attempt noted and appreciated. -- ilyas
                 \_ "Trolls are anyone that disagrees with you," a motd
                    person, circa May 2004
                    \_ You are right, it was a thoughtprovoking question.
                         -- ilyas
                        \_ I was actually quite serious you self righteous
                           bastard.  You're always going off about all these
                           obscure little languages and I actually really
                           wanted to know what use they are outside academia
                           but frankly I don't give a damn now.   If you don't
                           know or don't want to bother explaining then just
                           don't.  I certainly wasn't trolling.  --bite me
                 \_ This is a legit. question. What exactly is it that makes
                    this language (and/or any other language you keep talking
                    about on the motd) much better than C? I've looked up
                    things like ocaml and such, but they just seem like ya
                    syntax to learn w/o any added benefit (the resulting code
                    doesn't look any easier to write/debug/maintain than C).
                    Its not that I have anything against learning new prog.
                    langs (I've been working on ObjC to do Cocoa/OSX stuff),
                    its just that I want to know what the real benefit is
                    of these non-C-like langs that you keep mentioning.
                    \_ Well, I can't answer this for you.  _I_ find that GC
                       languages with good libraries infinitely easier to
                       get work done in than C.  YMMV.  Prolog is one of those
                       languages where if you are solving the right problem
                       the solution is 10 lines, and would have been 300 lines
                       in pretty much anything else (not a made up example).
                       Prolog also has fast implementations, since there's a
                       good mapping between prolog code and C.  Also, I agree
                       with Dijkstra in that poking with new languages can
                       teach you about programming, so it's certainly good to
                       learn other languages just for that reason, even if you
                       don't plan to use them in practice. -- ilyas
                       \_ The only benefits of C are: there's a C compiler for
                          nearly every platform--okay there's only 1 benefit.
                          GC is a non-issue really, and I've seen as many
                          problems with GC as without.  But yes, an important
                          reason to learn many languages is that some concepts
                          are easier to implement in different languages, hence
                          you actually think about doing things differently.
                          It's better to have many tools in the box than to
                          have a reeeeally good hammer. -emarkp
           \_ Is there something in the language itself that dispose it to
              slower implementation or just nobody bothers to make the effort?
              \_ Troll attempt noted and appreciated.  -- ilyas #8 fan
              \_ I don't know about Haskell.  Ocaml is about as fast as gcc
                 compiled C.  Does that answer your question? -- ilyas
2004/5/19 [Computer/SW/Languages/C_Cplusplus] UID:30294 Activity:nil
5/19    Quick poll for professional C++ programmers (that is, you use C++ in
        code you write for work):  Have you heard of Nicolai Josuttis or Andrei
        Alexandrescu?
        Both: ..
        Josuttis only:
        Alexandrescu only:
        neither:
2004/5/19 [Computer/SW/Languages/C_Cplusplus] UID:30293 Activity:nil
5/19    What kind of coding makes more? Around how much?
        c:
        c++:
        c#:
        vb:
        javascript:
        java:
        html:
2004/5/13-14 [Computer/SW/Languages/C_Cplusplus] UID:30202 Activity:very high
5/12    nCircle is looking for an experienced software engineer.  See
        /csua/pub/jobs/nCircle.sweng
        \_ so I have been doing java, and I still believe I'm an expert
           c/c++ programmer.  However, if you ask me what are
           the printf format parameters, I doubt I could tell you much
           other than %s.  So I can definitely get a book on c/c++ and
           \_ You are not an expert.  You are a fool.  Fortunately, you are
              dangerous only to yourself.
              \_ agree on being a fool part. If you are not making 100k with
                 an expert skill, you are a fool.
                 \_ What expert skill?  Not knowing printf?
                   \_ unless you are working with a company that use printf
                      all day long.  Not every app require printf, some you'll
                      never need it.
           start cramming, but I feel like it's pointless.  It's like
           someone asks me what's the difference between a semaphore and
           mutex, I can't really articulate.  Then when I really start
           doing the kind of work that relates to the topic I can do a
           very good job.  I am bring this up because I want to understand
           in real world how someone like me get around the barrior.  My
           experiences with a few people at companies is that they can tell
           the technicle stuff from cover to cover, but their work is just
           horrible. And they work at extremely slow pace; they don't seem to
           know how to debug their own code; they use the most inefficient
           they use the most inefficient
           algorithms (I would have no problem with that if they can deliever
           quicker which leaves room for optimization).
                \_ I'm in the same boat as you, and have been wondering about
                   this...  Learning/knowing how to learn, instead of just
                   rememebering details...
                   \_ If you need to ask, you should go and study the subject
                      and know the minutiae.  There are people who get by
                      by being brilliant.  You are not one of them.  If
                      you are, you wouldn't be here asking if you need to
                      know something.
           \_ C and C++ are quite different from Java.  The languages all have
              different idioms.  Being an expert in Java does not make you an
              expert in C or C++, even with a cram session.
              \_ All the programming skills are transferable.  I was doing
                all c/c++ programming for 6 years before switching to Java.
                Picked up java without reading a java book.  I all did was
                have the online Java API in my browser.  Now I'm coding with
                struts framework with online references.  In less than a year
                time at the current company I have already developed 3 voice
                applications (come in this company without any voice background
                \_ well, I'd expect going from C or C++ to Java is easier than
                   the other way around.
                   \_ yes, it is.  In essence, Java produce bad programmers
                   because java programmers wouldn't know how to manage
                   memory efficiently, they'll also most likely run into
                   alot of memory leaks when trying code c/c++
                   \_ I think that's silly.  Programmers are not
                      produced by the language.  Bad programmers are
                      bad because they are lazy or dumb or
                      inexperienced, not because they use
                      garbage_collected_language_001. -- ilyas
        \_ you said you are looking for someone who loves coding instead of
           money, does that mean the position will be less than $80K?  There's
           always a balance between love and bread.
                \_ the salary is competitive.  -brian
                \_ anytime they ask for "lots of passion/$" they're implying
                   that they want new, clueless fresh out of college grads
                   who have no idea what they're worth so that they can pay
                   very little for the biggest bang/bucks. Been there,
                   done that, and places like this are usually managed by
                   lame management. In fact, screw the passion. No matter
                   how interesting/challenging the job is and no matter how
                   much passion you have, the job will get boring after
                   4-5 years. The sooner you realize this the better  off
                   you'll be.
                   \_ agree 100%. Been there done that and still there! No
                   matter how productive I am, how much I have offerred, no
                   a sign of appreciation, still counting my clocks.  So I'm
                   also counting clocks.
                   \_ Yep. Hey kids, work your ass off for 12 hour days because
                      you believe in the company! We're all a happy family,
                      work hard but just play harder! Here kid, do this tedious
                      shit that nobody else wants to deal with, you'll learn a
                      lot! Oh hey kid we have to lay you off now, bye.
2004/5/11 [Computer/SW/Languages/C_Cplusplus] UID:30157 Activity:high
5/10    Can I create arbitrary blocks of code in C without control structures?
        I really just want something I can "break" out of.
        GetLock(myLock);
        {
          rc = SomeLibraryCall();
          if (rc < 0) break; // breaks to release lock
          rc = SecondLibraryCall();
          if (rc < 0) break;
          printf("Success\n");
        }
        ReleaseLock(myLock);
        return rc;
        Furthermore, is this advisable, or is there a better way to do it?
        \_ Yes, you can create arbitrary blocks.  No, you can't break out of
           them; "break" is allowed only within loop and switch blocks.  Use a
           goto if you must, or maybe even a do { ... } while(0) if you feel
           strongly against gotos.  In your example though, I'd just use
           if/else. --jameslin
        \_ As jameslin said, but here's the solution:
        int SomeFunction(void)
        {
            ...
            GetLock(myLock);
            int rc = SomeLibraryCall();

            if (rc >= 0)
            {
                rc = SecondLibraryCall();
                if (rc >= 0)
                {
                     printf("Success\n");
                }
            }

            ReleaseLock(myLock);
            return rc;
        }
        \_ Thanks both, but the problem is that it's not just SecondLibraryCall,
           it's NinthLibraryCall and it's getting ugly.  I think I'll use a
           goto ERROR sort of setup in the future.
           \_ How's this:
        int SomeFunction(void)
        {
            ...
            GetLock(myLock);

            while (1)
            {
                int rc = LibraryCall1();
                if (rc < 0) break;
                rc = LibraryCall2();
                if (rc < 0) break;
                ...
                printf("Success\n");
                break;
            }

            ReleaseLock(myLock);
            return rc;
        }
        \_ I'd rather not use a loop, even a fake one, because it implies
           ... well, a loop.  Same with the do / while above.  I guess I'm
           looking for a try { ... } block, but it's gotta be C.
           \_ what's wrong with implying a loop? Use the tools the language
              gives you. If you're so concerned use "for (i=0;i==0;i++)".
           \_ Totally correct.  How's this:
        int SomeFunction(void)
        {
            ...
            GetLock(myLock);

            int rc;
            if (   (rc = LibraryCall1()) >= 0
                && (rc = LibraryCall2()) >= 0
                && (rc = LibraryCall3()) >= 0
                ...
               )
            {
                printf("Success\n");
            }

            ReleaseLock(myLock);
            return rc;
        }
        \_ guys guys guy, you realize that gotos are allowed in C right?
           \_ ob GotoConsideredHarmful
              \_ This is where goto is the best solution.
2004/5/11-12 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Compilers] UID:30151 Activity:low
5/10    On a 32 bit architecture, if I declare something boolean or byte,
        does it still use 32 bits, or is it possible to have a different
        offset for the alignment to pack it more efficiently? ok thx.
        \_ For boolean, it's all up to your compiler.  For byte, most likely
           it's 8 bits, but it's still up to your compiler.
           \_ I heard that if the alignment isn't 32, either the arch
              would raise an off-alignment exception, or that there is
              a tremendous run-time penalty for the memory access. Is
              this true, and which architectures would this apply to?
              \_ memory alignment has nothing to do with this, since
                 you're presumably not trying to load a 32 bit word
                 from an arbitrary offset. if bool is implemented as
                 a char, then typically it's 8 bits and alignment
                 doesn't matter. x86 allows loading words from arbitrary
                 offsets, but there can be a significant performance hit,
                 whereas many mips style chips just do not allow it.
                 \_ To clarify this: the 32-bit alignment the previous poster
                    was worried about is only for 32-bit data values.  If you
                    have an 8-bit piece of data, it only needs 8-bit alignment.
              \_ The OpenBSD guys were saying that Sparc64 was their
                 preferred dev/testing arch b/c it has strict memory
                 alignment requirements; i386 less so.
              \_ On i386 or above, if you use 32-bits and it's not 32-bit
                 aligned, there is a performance penalty but no exception.
                 If you use 8 bits, I think for some instructions there is a
                 performance penalty just from using 8 bits instead of 32 bits
                 (excpet on the SX-variant processors.)  However, I think there
                 is no additional performance penalty if the 8-bit datum is not
                 32-bit aligned.
        \_ Do you mean 'bool' and 'char' in C++?  Or some other language?
2004/5/10 [Computer/SW/Languages/C_Cplusplus] UID:30126 Activity:low
5/10    How do I make emacs search currently highlighted words in current
        document? like f3 (or was it ctrl-f3) in windows? thx
        \_ there isn't a functionality exactly identical to that, but here
           are two ways to do similar things:
           1) place cursor at the start of the word(s) you want to search
              for.  press C-s, and repeat C-w until the selection includes
              all the words you want to search for.  then press C-s until
              you find what you want.
           2) highlight the term you want.  press C-s, then M-y (or
              Esc-y).  press C-s until you find what you want.
           \_ Also, please do "M-x describe-key C-s" to see other neat things
              you can do with C-s.  And C-r is for searching backward.
           \_ THX!!
2004/5/6 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Compilers] UID:30054 Activity:moderate
5/6     I'm trying to use "#define errno WSAGetLastError()" in a winsock
        file, but the compiler says errno is already #def'ed.  I can't
        just run cpp on the file--it's a crappy ide-based compiler--so
        I'd like to do something like printf("errno"), but of course that
        just prints "errno" instead of the preprocessor's notion of what
        errno is #def'ed to.  What should I do instead?
        \_ errno is already defined because it's part of the c-library.  Do
           One of the following:
           call perror() : This will print an error description to stderr
           use strerror(errno) to get the error string and print it however you
           want
           use strerror_r(errno, mybuffer, mybuffer_length) to put the error
           string into your buffer mybuffer
           \_ Sorry, should have explained myself a bit more-- this is a socket
              protocol wrapper file that's compiled into windows, unix, cygwin,
              and vxworks objects.  I'm doing a lot of
                rc = select(...);
                if (rc && EWOULDBLOCK == errno) { /* handle blocking error */
              so I really need the #def to work correctly.  I could just undef
              errno for winsock and then re-#define it, but I'd like to know
              what it evaluates to first.
        \_ Many compilers allow you to compile only the preprocessor step.  For
           instance, with Visual C++ 6 you can add "/E" to the compile options
           and you'll get the preprocessor output in the build window (and .plg
           file).
        \_ May I ask why you need to alias WSAGetLastError() to the preexisting
           #define errno?  Why not use a different label?
           \_ Every library except winsock uses errno to report the error, so it
              seemed relatively natural to keep it consistent.  I guess I could
              use MY_FOO_ERROR instead, but that would require a #else to the
              #ifdef _WINSOCK_H.  Also, I'm kinda curious how to print the
              evaluated macro at runtime.
        \_ if you really wanted, you could #undef errno first.  I don't see
           what using a crappy IDE-based compiler has to do with anything;
           it doesn't stop you from running cpp.  Anyhow, if you want to see
           what errno is #define'd to, see this:
                http://www.eskimo.com/~scs/C-faq/q11.17.html
           --jameslin
           \_ Thanks, this is exactly it.  Errno was #def'ed to *_GetErrno()
              and I didn't want to #undef it if it was already "magically" set
              to WSAGetLastError by <winsock.h>.  Also, running cpp on the file
              says that errno was #def'ed to *__errno().
2004/4/30-5/1 [Computer/SW/Compilers, Computer/SW/Languages/C_Cplusplus] UID:13508 Activity:moderate
4/30    Quick C++ question. In Meyer's More Effective C++, Item 22, he has
        a snippet of code like this:

        template<class T>
        const T operator+(const T& lhs, const T& rhs)
        {
          return T(lhs) += rhs;
        }

        My question is, why is it legal to do 'T(lhs) += rhs;'? T(lhs) yields
        a temporary, which is AFAIK, an rvalue, so since operator+= is not a
        const member function, the compiler shouldn't allow that line. My
        reading of the C++ standard seems to support my line of thought. But
        OTOH, g++ 3.4.0 happily accepts code similar to the above. So am I
        missing something here? Thanks.
        \_ T(lhs) is calling the copy constructor, which returns an object;
           I don't think it counts as a temporary.  Not sure though.
           \_ No, T(lhs) is the functional cast expression, which may call a
              constructor (but not the copy constructor).  Section 5.2.3/1 of
              the standard says that T(lhs) (that is, a type followed by parens
              and a single argument) is equivalent to (T)lhs.  5.4/1 then says
              that (T)lhs for a REFERENCE type is an lvalue, but for a
              non-reference type it's an rvalue. -emarkp
              \_ I agree with what you say, except for the part where you say
                 a copy constructor can't be called. That's illogical, and I
                 don't see where the standard says anything about that anyway.
                 \_ Well, that's the only part that isn't clearly in the
                    standard, so I'm glad you agree with the rest. :)  Anyway,
                    the standard says that: T(x) is equivalent to (T)x, which
                    any compiler will turn into a noop if the type of x is T.
                    I guess one exception for this would be if the type of x is
                    T const.  In which case I guess it would call the copy
                    constructor if T is not a reference type.  T *is* a
                    reference type in the example though. -emarkp
                    \_ Oops, my bad.  Yeah, this would call the copy
                       constructor (what was I thinking?) because of course lhs
                       can't be modified, but since lhs is a reference type the
                       copied object is an lvalue.  I'm sure this is one of the
                       screwy type rules that was made precisely for operator
                       overloading.  Sorry for the screwup. -emarkp
                       \_ Hmm, I don't think so. lhs may be of reference
                          type, but T(lhs), which is the same as (T)lhs, is of
                          type T, which is not necessarily a ref type. -op
                          \_ Okay, section 3.10/10: An lvalue for an object is
                             necessary in order to modify the object except
                             that an rvalue of class type can also be used to
                             modify its referent under certain circumstances.
                             [Example: a member function called for an object
                             (9.3) can modify the object.]  So it *is* being
                             copied, and it *is* an rvalue, but non-const
                             member functions can modify an rvalue of class
                             type.  -emarkp
                             \_ That's nasty, but thanks! -op
        \_ Ob: And this is why C++ sucks.
           \_ I agree it is often way too complex, but it has its moments. -op
           \_ Ironically, the reason this is so complex is so that it will work
              like you expect, or in a way that a compiler can optimize well.
              \_ Disagree.  At a certain point of complexity it's no longer
                 economical to expect anything.  All of this would be irrelevant
                 with T.add(lhs, rhs).
                 \_ Are you arguing against overloaded operators?  In your
                    expression, where does the sum go?
                    \_ It's returned as an instance of of T.  I'm not being a
                        smartass here, I'm just wondering about cases where
                        operator overloading saves anything more than a few
                        characters of function name.  What's the real win?
                       \_ Operator overloading is essential to having
                          user-defined types that don't feel like second-class
                          citizens. "Smart pointers" would be syntactically
                          ugly and cumbersome to use if you couldn't overload
                          pointer-ish operations, for example. I'm sure there
                          are lots more examples when you start using c++ as
                          more than just "a better C".
                          \_ To whoever asked why ocaml syntax is so warty
                               -- in part because ocaml has no operator
                               overloading.  I sometimes wish it was there,
                               but I am not holding my breath.  The ocaml way
        \_ Perl.
                               is that the operator can only be the same if
                               the underlying algorithm is the same (so for
                               instance they have +. for floats and + for ints,
                               but < for both floats and ints).  So they have
                               'polymorphism' instead of 'overloading'.
                                 -- ilyas
2004/4/30-5/1 [Computer/SW/Languages/C_Cplusplus] UID:13494 Activity:nil
4/30    C-50 (w/ help from Cl):
        http://www.newscientist.com/news/news.jsp?id=ns99994942
2004/4/28 [Computer/SW/Languages/C_Cplusplus] UID:13422 Activity:high
4/28    I use astyle to indent my C code, but on some files it chokes and starts
        indenting some 13 spaces (instead of 3) at some point down in the file,
        usually write below the function definition.  I can't find anything
        that looks odd about the function or the code above/below it.  Any ideas
        as to what is going on?  tia.
        \_ 4 spaces is the standard!
        \_ To answer my own post, the function was "int returnStatus(char *buf)"
           Changing it to rturnStatus (temporarily) fixed things... I guess it
           saw the "return" part as a keyword.
2004/4/21 [Computer/SW/Languages/C_Cplusplus] UID:13308 Activity:nil
4/21    In programming speak we call a # a hash and a ! a bang.  Is there
        a jargon name for ~?
        \_ tilde.
           \_ seconded
        \_ squiggle
        \_ twiddle?
           \_ I concurr.
        \_ I tend to call "#" a pound.
           \_ more discriminating people have tended to call this 'sharp',
              e.g. in K&R. pound is for phones.
              \_ Maybe, but #! being called sharp-bang seems odd.
                 \_ not really. #! is called shebang, which would seem
                    to be a shortening of sharp-bang.
                    \_ Far more often referred to as "hash-bang", shortened
                       to "'sh-bang."  Let's not reference Mr. Hung any more
                       than necessary.  And, btw, the only appropriate place
                       it's called a "sharp" is in music... Fuck C# --scotsman
                       \_ I agree that # is properly called hash. I hate
                          calling it a pound, that's for British currency.
                       \_ Jargon File says:
                           shebang:
                           "The character sequence #! that frequently begins
                           executable shell scripts under Unix. Probably
                           derived from "shell bang"..."
                           In any case, like I said, I think K&R calls it a
                           sharp, and I sure wouldn't trust your judgment
                           over K&R's. Also, I don't care for your "Fuck C#"
                           justification at all -- you sound like a tool.
           \_ Wasn't the original name 'octothorp' coined by the bell
              folks? -saarp
              \_ Surely something so obtuse could only have come from IBM?
        \_ what's @ called?
           \_ yomama
           \_ at.
           \_ In Korean it's called a "snail."
           \_ it's an onion
           \_ cinnamon roll
        \_ What do you call a "*"?
           \_ star
           \_ Splat.
              \_ That's what I call it too, but only Berkeley people seem
                 to use this.
2004/4/20 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Java] UID:13283 Activity:nil
4/20    How does on change the indention level for Java Mode in emacs?
        I understand the C variable is c-basic-offset, but what's the
        Java variable?  (Hint: It's not java-basic-offset) Help?
        \_ Dude this has been posted like, the 10th time this year.
           http://csua.com/?entry=12982
           Use the force, just f****** search!!!
           \_ Wow, you're a freaking genius.  That tells me exactly
              how to NOT do what I want.  THANKS!
                \_ dumbass, the fine print says: "do 'info ccmode' and look at t\
he section on hooks."
        \_ the following works for me, maybe you can try it:
(setq java-mode-hook
      (setq
       c-indent-level 4
       default-tab-width 4
       c-basic-offset 4
       indent-tabs-mode nil
       )
      )
2004/4/16-17 [Computer/SW/Languages/C_Cplusplus] UID:13241 Activity:nil
4/16    What C++ programs out there (with source code freely available) do you
        guys think are particularly well-written, elegant, etc.? That is, what
        would you read to improve your understanding of what constitutes good
        C++ code? Thanks.
        \_ Anything not written by M$.
        \_ LEDA
           \_ the source doesn't seem to be freely available for that one.
              at least, not if those hoops i see over there are for jumping
              through.
2004/4/14-15 [Computer/SW/Languages/C_Cplusplus] UID:13199 Activity:nil
4/14    What are the industry trends towards Java jobs?  What about
        C/C++ jobs?
        \_ India
2004/4/13-14 [Computer/SW/Languages/C_Cplusplus] UID:13175 Activity:high
4/13    How much C++/C knowledge do recent Berkeley CS/EECS grad have?
        \_ Class CSGrad inherits FromDaddy and does not implement C++Knowledge
           very well.
           \_ funny.  just the rich and poor as always.  the middle class can't
              afford education.
        \_ They know how to deal with pointers and addresses, malloc and free.
           They also know OO.  Understanding the intricacies of how C++ bridges
           those two worlds is up to the individual, and probably picked up
           fairly quickly.
           \_ "Nobody understands C++."  C++ is big enough that it swallows
              other languages (for instance it has a small functional language
              completely embedded in the template syntax alone).  -- ilyas
              \_ This is just plain silly.  C++ has esoterica and dark corners,
                 but the vast bulk of it is easily understood with some effort
                 and training.
                 \_ 'Easily.'  It will take you many years to write efficient,
                    maintainable C++ code.  It will take many more years to
                    be a 'guru'.  I am not sure any one person understands
                    all of C++.  I will grant you that the 'java subset' of C++
                    is easy enough.  Even an 'easier' language like java has
                    some things that give even experienced people pause
                    (anonymous inner classes, etc). -- ilyas
           \_ written by someone who apparently doesn't know much c++. the
              real intricacies of c++ are not picked up fairly quickly, which
              is one of the major issues people have with it. it is big, and
              hard (no porno comments, please). to answer the op though, as a
              recent grad, i claim that the vast majority of berkeley eecs/cs
              people have a pretty shallow knowledge of c or c++, partly
              because almost all the classes have a java option now.
              \_ Well put it this way: it's pretty easy to pick up a few simple
                 rules that reduce C++ to a simple(r) productive language.
                 \_ which still isn't C++.
              \_ Um, no, they don't know how to deal with pointers, addresses,
                 malloc or free.  Most *typical* Berkeley CS grads in the last
                 three or four years couldn't tell their ass from a pointer
                 and stare blankly at you if you say ``memory management.''
                 A lot of nonsense goes on in the CSUA, but I will say that
                 most recent grads who kicked around a little with the CSUA
                 have at least an acceptable level of understanding of C, and
                 some may show passable C++ knowledge. -dans
                 \_ Mostly correct I'm afraid.  I learned C++ through my
                    research, not my classes, and I would barely classify
                    my knowledge as passable.  (We used a garbage
                    collector, I felt like I was cheating)
        \_ not as well as they used to say 5-8 years ago.  but given that
           the department always says "we're not here to teach you languages,
           you're supposed to pick them up on your own," things could be worse.
2004/4/6 [Computer/SW/Languages/C_Cplusplus, Academia/Berkeley/CSUA/Motd] UID:13031 Activity:nil
4/5     Dude, can you guys PLEASE PLEASE wait 12 hours before deleting a
        helpful message (relating to tech/computer/sysadm/etc)? Thank you.
        \_ fuck you.  when people delete politics, tech stuff gets deleted.
           \_ You pathetic baboon, what does deleting political crap have
              to do with someone nicely asking that informative tech posts
              be kept?  Grow up.  -John
              \_ John, stop deleting stuff, and stop using racial slurs
              \_ neither should get *censored* but it seems to be a very
                 simple lesson in tit for tat.  some people want the motd to
                 be techie-only and censor things they don't care about.  they
                 don't listen to those who have asked for years to not do that
                 so you're now seeing the response of frustrated last resort.
                 the lesson is something your mother should have taught you by
                 age 5: treat others as you'd have them treat you.  there's
                 nothing sacred about techie posts.
                 \_ Wait, take this example:  Person A Makes a technical post.
                    Person B makes a political post.  Person C delete's B's
                    post.  You're saying it makes sense for B to delete A's
                    post?  That sounds like completely ineffective collective
                    punishment.
                    \_ Yes, it does.  It punishes C who wanted to keep A.
                 \_ in other words, the trolls get pissed when their attempts
                    at making the MOTD useless by inciting stupid arguments
                    fail, so they go straight to deleting the useful content.
                    \_ this line of reasoning is exactly the problem here.  you
                       think the motd is only for "useful" (to you) threads on
                       topics of interest (to you) and anything else is a troll
                       which makes the motd useless.  when you get over it and
                       finally understand the motd is a public space for
                       everyone, it'll be more useful for everyone.  tit for
                       tat is a very simple concept you should have learned
                       in grade school.  everyone loses.  so stop deleting the
                       topics that are obviously not trolls and are of great
                       interest to others and yours will stick around longer
                       too.  if we measured value by number of replies, length
                       of replies, effort spent in replying, and number of
                       people involved in each thread, it can be easily
                       argued that the motd is primarily for political topics
                       with a secondary function for google-able techie
                       questions and a few job postings.
                       \_ Anything can be argued.  Anyone arguing that the
                          MOTD is a good place for political topics would
                          sound like a complete idiot, but he certainly
                          could argue it.
                          \_ Score another ad hominen.  Got anything to say?
           \_ and destruction begets more destruction.  brillant.
        \_ and you would delete everything else?
           \_ ln -s /etc/motd.public /dev/null
                \_ Permission denied, can someone with root do it please?
2004/3/27-28 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Python] UID:12891 Activity:moderate
3/27    Funny argument involving code, recursion, and a foxtrot comic:
        http://www.pantsfactory.org/?action=comments&linkid=1260
        \_ somehow that thread neglects to provide a link to the 1.0.1 patch:
        \_ somehow that thread neglects to provide a link to the patch:
           http://homepage.mac.com/billamend/images/patch.gif
2004/3/25-26 [Computer/SW/Languages/C_Cplusplus] UID:12861 Activity:nil
3/25    Please confirm:
        int foo(void) {
          static char *str = (char*) malloc(10000 * sizeof(char));
          ...
        }
        malloc will only be called once, correct?
        \_ It will be called everytime the function is called.
           You may want to look at __attribute__((constructor)) if
           you are using gcc.
           \_ Uh, if it were evaluated every time the function is called, the
              "static" keyword would be totally useless.  To the OP, if you're
              using ANSI C, that's not a legal construct.  Static variables
              are equivalent to global variables with restricted scope, so you
              can't initialize them to non-constant values.  It's fine in C++;
              C++ initializes static variables at run-time.  If you're using
              C++, though, you probably ought to use new instead of malloc, or
              there are probably better ways to do whatever it is you want to
              do.
        \_ you easily can test this by replacing the malloc call with
           printf/cout/whatever.
2004/3/19-20 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Perl] UID:12756 Activity:nil
3/19    When I do substr($string, x, 1) eq "c" in Perl, is it smart enough
        to do (string[0]=='c') in lower level, or is it dumb to do it
        like strcmp(string, "c")==0? In another word how much optimization
        does Perl perform? I'm asking because performance is an
        issue but I don't want to use C. ok thx
        \_ umm...why do you think strcmp(string, "c") would be so slow?
           oh, right, because you're an idiot.
        \_ Profile your code.  You will almost certainly be surprised to learn
           where the real slowdown is. -- ilyas
           \_ it won't be in this trivial string comparison, that's for sure.
              \_ Indeed not. -- ilyas
                 \_ makes me wonder what they're teaching in Berkeley CS these
                    days....
        \_ Use C or another REAL programming language.
2004/3/15-16 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Perl] UID:12666 Activity:low
3/14    Is there a function that takes a string and then escape all spaces
        and control chars in it and return a string suitable for use as
        say a filename in a shell?  tia.
        \_ "function" in what, c, the shell, ...?
           \_ in some more or less widely available library of C functions?
              \_ Something like perl's quotemeta? --scotsman
              \_ No. But if you want to look at an example look in
                 openbsd's ksh. IIRC, the function is called x_escape
                 and is in edit.c.
                 \_ Thanks.  One would have thought something has useful as
                    this should make it way to some standard lib.  Not that it
                    is that difficult, but why reinvent the wheel or copy
                    other's work?
2004/3/12-13 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Misc] UID:12645 Activity:nil
3/12    Iway'may eryvay eryvay impressedway atway owhay icklyquay ethay otdmay
        ormattingfay odgay ormatsfay may intentionallyway illway ormedfay
        ostspay. Iway'may onderingway ifway itway'say actuallyway away
        onedcray ormattingfay iptscray orway omethingsay, andway ifway osay,
        ancay youay easeplay ostpay ethay iptscray? anksThay
        \_ It's no script.
           \_ That's no moon.
        \_ Why do YOU care?
           \_ Wow, motdedit fixed up my post pretty funny.  This was
              supposed to be on the Jessica Lynch post, but someone
              deleted it.  I can't say it's any less applicable here
              though...
        \_ The motd formatting devil was here
        \_ I'm pretty sure there is no script as this is a pretty complicated
           problem (context sensitive flow analysis with statistical
           inference, etc). However, I do think that whoever does the
           formatting is equivalent a very complicated finite state automaton
           that runs in an infinite while loop.
           \_ it's not that hard.  parse the motd looking for a newline
              followed by a number to get the start of a post, then anytime
              you see a "\_" or "\-" preceeded by tabs or spaces you get a
              change in authorship.  the actual reformat is trivial.
                 FUCK its hard because there are so many corner cases. For _|
                 U example, suppose I interrupt your line in the middle, then
                 C your parser will get fooled. The other example is if I
                 K start posting in ascii pictures. Then what if I jive your
                 F content? And what if the indentation IS indeed unusual
                        like a C/Java code? ANd what if I use letters
                           I_ to indicate a response? And the list goes
                              on and on, but the point is, it's very easy
                              for the naked eye to catch infinite weird
                              cases, but putting them into smart/self-learning
                              generic rules is just as hard as writing
                              spamassassin.
                \_ Corner cases?  fuck em, its the motd.  this isn't one of
                   hilfinger's courses.
                   \_ I am Gunnery Seargent Hartman, your Senior Drill
                      Instructor.  From now on, you will speak only when
                      spoken to, and the first and last words out of your
                      filthy sewers will be "Sir!"  DO YOU MAGGOTS UNDERSTAND
                      THAT?!
                      \_ SIR YES SIR!!!!!!!!!!!!!
2004/3/11-12 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Misc] UID:12613 Activity:moderate
3/10    Teach yourself programming in 10 years:
        http://norvig.com/21-days.html
        \_ "Learn at least a half dozen programming languages"
           Why? What is the point of knowing a bunch of languages
           when the only language that is of any real use is C?
           \_ Assuming this is not a troll I'll just throw in that I know
              more than a couple of people who have been slow to get re-
              absorbed into the employment pool because they could not claim
              to be experienced and proficient in more than one language. As
              an outside observer, it really looked to me like they should have
              been augmenting C with Java or J2EE with C++ and so on...
               -- not a cs professional
           \_ Did you study CS at Berkeley?  If you want to get any
              real work done, you ought to use high-level languages.
                \_ if you want any real job you need to know more than 1 lang.
                \_ I didn't study CS (I was an eng.) I'm not sure
                   what you characterize as real work, but I've
                   worked on device drivers, custom embedded
                   oses and encryption protocols; all in C.
                   \_ "Hydrological _and_ hydrodynamical!  Talk about
                   \_ "Hydrological _and_ hydroelectrical!  Talk about
                      running the gamut." -- ilyas (though the credit has to
                      go to Sideshow Bob)
                      \_ The first mention of my profession on the motd,
                         ever! Well, actually I kind of gave up on hydrology.
                         -- ulysses
           \_ Because really learning another language means learning what
              its strengths are and understanding why those are strengths.
           \_ It's better to learn new languages naturally as the need arises.
           \_ I don't know why I bought all those tools when the only
              \_ BAM!
              tool of any real use is the hammer.
2004/2/25-26 [Computer/SW/Languages/C_Cplusplus] UID:12407 Activity:nil
2/24    Another (more focused) script question- what's the best language to
        quickly wrap a (1) C library (eg, socket manager) (2) C++ class?
        Does (2) get any easier if I use non-virtual methods?
        \_ python
2004/2/10-11 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Java] UID:12201 Activity:kinda low
2/10    What is the equivalent of "protected static int COUNTER=0" in C++?
        Either protected or private would be ok. Thanks!
        class foo {
           protected:
             static int COUNTER;
        };
        in foo.cpp
           int foo::COUNTER = 0;
2004/1/30 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Functional] UID:12020 Activity:nil
1/29    Anyone know what strpbrk (the c library function) stands for?
        \_ http://tinyurl.com/2bupw (developer.apple.com)
           \_ He's not asking for the manpage; what does the pbrk part mean?
              \_ probably STRing Pointer BReaK, if someone has the ISO C 89
                 standard they could look it up.
                 \_ that's the obvious guess, but if you think about it,
                    it doesn't really...say anything. btw, i have a copy of
                    the c standard, and what it means is not mentioned.
                    it's also a strange name compared to say, strchr/strrchr,
                    which perform pretty similar functions, just on a single
                    character. -op
        \_ from the book:
                char *strpbrk(cs,ct) return pointer to first occurrence
                in string cs of any character of string ct or NULL if
                none are present.
                \_ You're not answering the question either.  The question is
                   about etymology.  Anyway, this is the sort of thing that
                   probably should be asked on comp.lang.c.
                   \- it means "in a STRing return P pointer to the first
                      BReaK character". you may wish to google for say
                      "lisp scheme skip-until parser break" --psb
        \_ From the BSD manpages it says :
           "strpbrk - locate multiple characters in string"
           From this I'm guessing you could use it to locate things like "\n\t"
           which would be a STRing Paragraph BReaK.
2004/1/21 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Compilers] UID:11861 Activity:nil
1/20    Any candidates for the best way to prevent developers from #includeing
        a header file accidentally.  Aside from very loud comments to that
        effect, what is a good way to make the compiler complain?  I was
        thinking something like
        #ifndef MYLIB_I_REALLY_WANT_TO_USE_THE_PRIVATE_INTERFACE
          // best way to cause compiler pain goes here
        #endif
        at the top of the private header file.  This has to be straight C for
        various reasons (I do prefer C++ and Java).
        \_ #include Your_error_message_here
           \_ Cannot find file Your_error_message_here
           \_ If you want to raise a preprocessor error, there's a mechanism
              for that: it's called #error.  #error Don't include this file.
              Anyhow, if you want to restrict access to, say, structure
              internals, you can do:
                #ifdef MYLIB_I_REALLY_WANT_TO_USE_THE_PRIVATE_INTERFACE
                    struct st
                    {
                        int field;
                    };
                #else
                    struct st { };
                #endif
        \_ Document your code and fire any developers who ignore specs.  If
           they're ignoring something this major, they will hose your source
           even worse somewhere else.
2004/1/15-16 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages] UID:11792 Activity:nil
1/14    Is there an enscript-esque tool for Win32 with a GUI?  I want to print
        source code including highlighting, formatting, etc.  Thanks.
        \_ Eclipse does a pretty good job of this, but it's a full featured IDE
           \_ UltraEdit too.
        \_ PrintFile32 -- it allows you to specify keywords for a language if
           it's not in the code.  Works great for C-like languages (I haven't
           really used it for other language families).
           http://www.lerup.com/printfile
        \_ the most lightweight is probably TextEdit
           \_ Thanks for the suggestions!  -op
              \_ Civility on the motd!?!  Begone!
2003/12/15 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Compilers] UID:11455 Activity:low
12/14   Sorry about this, but about alternative to the Dragon Book in the
        subject of Compiler.  What is the name of the author for that
        Programming Language book again?
        \_ the Tiger Book by appel- a much better read.
        \_ Michael Scott.  Here's the Amazon link if you want to read
           some reviews: http://tinyurl.com/z9rx
           \_ thanks
           some reviews.
2003/12/12-13 [Computer/SW/Languages/C_Cplusplus] UID:11439 Activity:low
12/12   Is there a good book on using C++ for large software projects?
        I suspect making this required reading for engineers will reduce
        likelihood of C++ code-bloat / vaporware problems.
        \_ Weak troll, or weak manager brain?  I am not sure which I prefer.
2003/12/12-13 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Compilers] UID:11427 Activity:nil
12/11   Is there something like __FILE__ or __LINE__ macro that will give me
        the class / method name in C++?
        \_ it can't be a macro, because the preprocessor doesn't know anything
           about classes or functions.
        \_ __FUNCTION__, __PRETTY_FUNCTION__ in gcc, __func__ in C99
           \_ gcc 2.95.4 on soda accepts __func__ too.
2003/12/11-12 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Compilers] UID:11404 Activity:moderate
12/10   I am not a programmer so this question may be stupid.  What does
        @"A string (might be empty)" mean in a gcc?
        \_ The '@' character has no meaning other than '@' in standard C.  Look
           at the documentation for your nonstandard compiler.
           \_ What's the meaning of '@' in standard C?  I have no C book
              near me and I can't find it in the documentation either.
              \_ It isn't standard C syntax. If you post a code snippet with
                 a usage example maybe we can guess what it is.
              \_ Sorry I wasn't clear.  The '@' is not an operator, token, etc.
                 It's just another character, like '1' or '8' or '\' and has no
                 special meaning at all.  However, it *does* have a special
                 meaning in C#.  Specifically it means a verbatim string
                 literal.  See:
                 http://www.softsteel.co.uk/tutorials/cSharp/lesson4.html#3
        \_ Please give more context.  Otherwise it looks like the program
           may be run through a custom pre-processor (@ is expanded to
           something else) before being passed to gcc.
        \_ What's the source language? Objective-C?
        \_ I think @ means something in Objective-C... unicode string maybe?
           \_ Apparently an "NSString" object: http://csua.org/u/58b
           \_ It means several things in ObjC. @"..." is a way to
              create an NSString literal, but it's used in other places,
              e.g., @class to predeclare a class name, @interface ... @end
              is how you declare a class, etc.
              \_ Thanks.  Now I realize that the version of documentation
                 stored on my computer is outdated.  It does not define the
                 @"string" directive even though it is is already in use by
                 then.  Actually it is still not in the grammar section
                 of the current documentation as far as I see.
                 http://tinyurl.com/ytlp (developer.apple.com)
                 \_ What variant of C are you using exactly?
                    \_ I am reading some Objective C codes for Mac.  As there
                       is no standard whatsoever for Objective C, I should
                       really say codes for the gcc compiler that comes with
                       OS X.  I am confused why this compiler can
                       be called gcc: NSString is part of Cocoa, which
                       is not GPL or open source.
                        \_ NSString is part of GNUStep which is open src:
                           http://tinyurl.com/ytlw (gnustep.us)
                           Also there are some "standards" docs for the
                           language:
                           http://pages.cpsc.ucalgary.ca/~burrellm/objc/objc.pdf
                       \_ It probably should be listed in the grammar, but
                          you will find it here: http://csua.org/u/58h
                          This static string syntax, I believe, is an ObjC
                          thing, and not an Apple extension (GNUStep
                 as far as I see.
                          docs refer to it too), but I couldn't test it
                          it out on soda, as I couldn't find the Foundation
                          header files.  http://csua.org/u/58i
2003/12/10-11 [Computer/SW/Languages/C_Cplusplus] UID:29701 Activity:high
12/10   No, seriously-- I really need a code formatter for C++.
        \_ http://www.google.com/search?q=C%2B%2B+code+formatter
        \_ How much formatting do you want?  Just indent?  Or do you want to
           parse the lex the code and rearrange {}'s ()'s whitespace, etc.?
           \_ indent chokes on c++
              \_ you didn't even answer the guy's question; why should
                 anyone answer yours?
              \_ Hey dumbass, I wasn't talking about /usr/bin/indent, I was
                 talking about indenting in general.
        \_ http://sourceforge.net/projects/astyle
           \_ How does Java style differ from K&R?
2003/12/8-9 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Compilers] UID:11359 Activity:low
12/7    Is there any reason to use bzero over memset(foo, 0, sizeof(foo))?
        \_ ANSI!  ANSI! is the STANDARD! C runtime library.
           (use memset instead)
           \_ Is ANSI the standard or is K&R (in the K&R C book) the standard?
              I've always been using the K&R book as reference when I want to
              write portable code.
              \_ K&R 2nd edition has a big "ANSI C" label on the cover.
                 I think "K&R C" refers to K&R 1st edition.
        \_ On some systems bzero used to have an optimized assembler
           implementation. If you are not concerned with speed, stick
           to memset() since it is part of C89.
           \_ Wouldn't those systems also have a quick compiler check to
              call the assembly when the second arg was 0?
2003/12/8-9 [Computer/SW/Languages/C_Cplusplus] UID:11356 Activity:nil
12/8    c++ question, how do I overload << in my class so it will handle
        endl? ie: myclass << "some string" << endl
        I know how to do the "some string" part:
                myclass & operator << (const char * s);
        what about endl?
        Thanks!!
        \_ I thought endl was just a regular char* too.
        \_ what self-respecting c++ programmer doesn't have a copy of
           stroustrup available? it's in there.
           \_ Don't know about you, but the stroustrup text blows chunks.
              It is nowhere close to being something like K&R. The text
              I usually refer to (but no doubt is incomplete, but hey, that's
              what you get with a badly designed kludge of a language) is
              the Lippman text we used in CS61B. I rarely have to use
              anything arcane like overloading operators, and I think
                                        \_ overloading operators is fine
                                           if it's not done stupidly.
                                           C = A + B has a very well-defined
                                           and clear meaning if A, B, C are
                                           square matrices of size N, for
                                           example.  Overloading + to do
                                           a matrix multiply would be a
                                           stupid overload.
              that most of the OO baggage of C++ is unnecessary. Not only
              that, it seems like popular APIs (i.e. kde, mfc)
              promote things like OO very inconsistently.
              \_ while i agree that c++ is pretty kludgy in many cases,
                 if you think operator overloading is "arcane", you must
                 not know c++ very well at all. do you prefer stuff like
                 a.add(b).multiply(c).divide(d)? and that's just for nice
                 short variable names. operator overloading is pretty cool, and
                 even guy steele thinks java will need it as it matures.
                 \_ uhg, is all berkeley cs lost? (/ (* (+ a b) c) d)  ;-)
                 \_ if you need to do things like add multiply and divide, sure
                    it makes sense... but how often do you need those
                    constructs? the Matrix example above was a good example.
        \_ endl is a manipulator, not a string constant.  In addition to ending
           the line, it flushes the buffer.
2003/12/4-5 [Computer/SW/Languages/C_Cplusplus] UID:11317 Activity:nil
12/4    Is there any reason to worry about mixing the usage of malloc and new?
        Obviously, you can't delete() malloc'd memory (and vv), but aside from
        that, will bad things happen?  Oh, I should note that this is for a C
        library that is used by C++ -- a coworker suggested wrapping my memory
        allocations (and deletions) with
        #ifdef __cplusplus
                foo = new char[100];
        #else
                foo = (char*) malloc(100 * sizeof(char));
        #endif
        \_ as long as you call free only on malloc-allocated memory and delete
           only on new-allocated memory, you should be fine.  If it were the
           case otherwise, then you wouldn't be able to link C++ code against
           C code.
2003/12/4-5 [Computer/SW/Languages/C_Cplusplus] UID:11316 Activity:nil
12/4    Is there a way to do a c/c++ log macro/function so that in the log
        message it will automatically output the filename/function name
        or something of that sort?
        \_ One (bad) attempt, just to give you an idea:
        #define LOGMSG logMsg(__FILE__, __LINE__,

        int logMsg(char *fname, int line, char *msgfmt, ...) {

           char msg[512]; va_list vl;
           va_start(vl, msgfmt); vsprintf(msg, msgfmt, vl); va_end(vl);
           printf("%s:%d : %s", fname, line, msg);
           return 0;
        }
        Macros don't allow varargs, so your uses of this macro are going to
          \_ http://docs.freebsd.org/info/gcc/gcc.info.Macro_Varargs.html
             \_ that's almost as cool as the shirt folding thing.  Thanks.

        look like
        LOG_MSG "This is error number %d\n", foo);
               ^ note missing "("
        The macro will expand this to
        logMsg(__FILE__, __LINE__, "This is error number %d\n", foo);
        and your log msg will look like:
        myfile.c:104 : This is error number 5
        It would be a lot nicer if you could define some standard log formats,
        then you wouldn't have to do that horrible horrible macro stuff.
        \_ You should use log4cplus.  I use it and it's fairly easy to
           configure.
2003/11/21 [Computer/SW/Languages/C_Cplusplus] UID:29654 Activity:high
11/20   I have a couple binaries (foo, bar) that I need to call from a C
        program, and I need to get their exit codes.  If I use system("foo")
        I'll get the return code of the shell that executed foo, so that's
        out.  What's the best way to pass back this single int of status info?
        \_ What OS?
        \_ What OS? -_ Unix
        \_ use exec() instead.
           \_ How do I get back to the context of my C program?  Exec never
              returns.
              \_ fork first
2003/11/6 [Computer/SW/Languages/C_Cplusplus] UID:10967 Activity:nil
11/6    How do i get the local port number of a socket after it connects
        in c? (solaris). i am doing socket() followed by connect()...
        Thanks a lot!!
        \_ I believe you can check the sin_port field of the sockaddr_in
           structure after calling connect().
2003/10/20-21 [Computer/SW/Languages/C_Cplusplus, Computer/Networking] UID:10702 Activity:kinda low
10/20   I need to design some sort of tcp socket system for responding to
        client commands (sent from a gui).  The client will be sending
        text strings such as "set_foo_bar_baz=2340", but usually more complex.
        The server delegates the command to a specific function, which will
        respond with a potentially large (10Kb) response string.  Is it
        possible to pass the socket descriptor to the command handler s.t.
        the handler can fprintf() to the socket?  Is this advisable?  TIA.
        \_ What's wrong with passing the socket descriptor and using
           send()?
           \_ print formatting, ease of use, etc.  Also, it's a realtime
              system and we can only allocate memory at startup.
              \_ How can you have a realtime system rely on tcp?  Are you sure
                 it's a realtime system? -- ilyas
                 \_ The socket code is running in a low priority task which
                    talks to the RT task.  I'm interested in the file
                    descriptor solution because a dynamic malloc (even at
                    low-pri) might be too slow... the alternative is a purely
                    static buffer allocation, which I then pass into the
                    command handlers... but formatted printing into a char
                    array (sprintf; strcat) isn't quite as nice as fprintf.
                    \_ I think the tcp latency will dominate any latency from
                       a dynamic malloc.  Mallocs aren't that slow, compared
                       to a slow network.  Unless of course, your tcp is local.
                       Even in that case, the protocol makes no guarantees
                       about delivery times, so it would be difficult to
                       convince anyone your system is truly real time.
                         -- ilyas
                       \_ The RT data is coming in over the system bus; tcp
                          is only used for command & control.  I'm not
                          experienced enough to actually know what's going on,
                          but my mandate is that malloc is a no-no.  At any
                          rate, it looks like the static malloc decision has
                          already been made.  Thanks for your help though.
                 \_ Must be Linux based.
        \_ http://members.cox.net/defiant_penguin/documents/basic-socket.html
           There, have phun.
           \_ I think phun is depreciated.
                \_ Really?  Can I write it off on my taxes?  Or do
                   you really mean deprecated?
                        \_ just read the link retard.
2003/10/12-13 [Computer/SW/Languages/C_Cplusplus, Recreation/Shopping] UID:10601 Activity:nil
10/11   My friend just asked me what "pegged pants" are. I couldn't find
        any good pictures on google. Any better googlers out there?
        This is as good as I could find:
        http://partyclothes.com/images/lilac_and_turq.jpg
        \_ Couldn't find pegged jeans, but this is pretty funny:
           http://www.inthe80s.com/clothes/p.shtml  -John
        \_ Why don't you fold your jeans, roll them, and let him see for
           himself.  If it helps, wear some reebok hightops (or vans w/ no
           socks) and a T&C Surf Designs shirt.  If you really want a picture,
           please take one and post it on the web, I'd like to see it too.
           \_ I did this last weekend for an 80's party. HORRID. Utterly
              horrid. If I end up with any pictures of myself, I'll make sure
              to burn them.
        \_ Does anyone have a copy of "The Official Preppy Handbook". Quotes:
           "Blucher moccasins or Sperry Top-siders?", "whales or ducks?"...
           "to Lacoste or not to Lacoste and if so collar up or down?"
2003/10/3-4 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Java] UID:10437 Activity:nil
10/2    Java's cover:
        http://www.paulgraham.com/javacover.html
        \_ The sun internal memo is good reading as well. Lots of projects
           at sun (and elsewhere) that need to provide robust functionality
           in a small memory foot print have rejected java in favor of c
           or perl because of the reasons outlined in that memo. Java might
           have been a good idea but its implementation is terrible.
           \_ 99% of applications out there don't need a small memory footprint
              \_ The embedded market is huge. That's who they're talking about.
              \_ You would be surprised how many applications that run on
                 general purpose hardware/os need to have a small memory
                 footprint per instance (and/or thread). When you have to
                 handle hundreds of simultaneous requests, something that
                 takes 10 mb of memory to just stand up and another 50 or
                 so to run (per instance) puts a huge burden on them system.
                 I'm not even considering the io/cpu load that a java pgm
                 places on the system. You can also forget about writing
                 cli utilites with java, since the startup time for the vm
                 is long.
                 \_ 1. 60 megs is nothing these days.  Really.  My laptop has
                    a gig of memory.  Any server should have more.  And java
                    doesn't take that much memory on my system.  And if you
                    make the vm constantly resident (for such things as
                    servlets) the startup time isn't an issue.  Look I'm not
                    saying Java is the One True programing language, I'm
                    saying nothing is.  Different tools for different jobs.
                    Java is pretty good at what it does.  And for the embeded
                    market it has worked pretty well too.  I for one think
                    the whole language world is pretty stagnent right now
                    and someone needs to create a c++ killer that, gives
                    you total control over memory, enables you to be as fast
                    as C if you need it, and isn't the ugly piece of shit c++
                    is.  Hell maybe someone should stop trying to copy C
                    syntax and typing and come up with something new that
                    works.  But until then I'll make do with what is out there
                    and for some jobs Java works well, for some perl, and
                    for other C++.
                    \_ Out of curiosity, how many languages do you know?
                         -- ilyas
                     \_ I've done major projects with c/c++, perl, and
                        java.  I have played around with lots of others:
                        python, smalltalk, ruby, eifle, ocaml, objective c,
                        and others I've forgotten about.  I'd love to do
                        a serious project in any of those, but I've never
                        had a reason to.  And as I've said, I'd really like
                        to see a good C replacement type language for doing
                        stuff C/C++ should be used for (which sadly is a lot
                        less than it IS used for.)
                        \_ I am an ocaml fan.  I think you can use ocaml for
                           most stuff people use c++ for these days, except
                           maybe some kinds of system work.  I like lisp too.
                           People think of lisp as slow, but it's not.  -- ilyas
2003/9/26-30 [Industry/Jobs, Computer/SW/Languages/C_Cplusplus] UID:10344 Activity:kinda low
9/26    I am looking to hire several experienced C developers to work on
        a network security product and a financial (stock trading) application.
        If you or anyone you know is looking for a job please email a resume to
        rjchu@hightowersoftware.com
        \_ Wow.  Is it an embedded product?  Or a legacy one?  Are you sure it's
           in C?
           on C?
           \_ It's gotta be .NET/C#/F# or Java
              \_ !C != .NET/C#/F# or Java
                 \_ You're just jealous because you don't have 10+ years of
        \_ I have 15+ years of Java, C#, and .NET!
           \_ Do you have over 10 years of HTML?
           on C?
           \_ It's gotta be .NET/C#/F# or Java
              \_ !C != .NET/C#/F# or Java
                    C# or .NET technologies and innovations on your resume.
                   \_ yeah, it didn't even exists until 3 yrs ago
                    \_ [ Someone discovering America by opening their window ]
2003/9/26-28 [Computer/SW/Languages/C_Cplusplus] UID:10338 Activity:nil
9/26    C question: if I have "static int alreadyRun = 0;" at the top of
        my function, will alreadyRun be set to 0 on every call, or merely
        the first call?  Thanks.
        \_ The value is set once at program start time, along with the
           global variables.  The value is not reset every function call,
           as that would defeat the purpose.
           \_ What about in C++? :-)
           \_ Not quite correct in C++ but I don't know if it's different from C
              in this respect.  The variable is required to be initialized
              before the first time it's used, so if you don't ever call the
              function it might never be initialized.  This isn't a major issue
              for an 'int' but it becomes very important with Singletons.
              \_ Funny.  I wrote this response and when I tried to save it, I
                 got a 'file has changed' warning.  The above C++ question was
                 added while I was writing this, and this time the C/C++
                 differences are important (at least for complex objects or
                 constructors with side-effects).
                 \_ If you have 10+ years of C/C++/Java please let me know.
                    \_ Let who know?  And why?
2003/9/19-20 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Compilers] UID:10257 Activity:nil
9/19    I have something like this:

        unsigned char a;
        char b;
        unsigned short c;
        short d;

        if (a < 9999999) {}
        if (b < 9999999) {}
        if (c < 9999999) {}
        if (d < 9999999) {}

        When I compile this with gcc 2.8.1 on SunOS 5, it only complains
        "comparison is always 1" for b and d, but not a or c.  Why?  Thanks.
        \_ Perhaps in converting 99999999 to a signed char or signed short
           the compiler wraps the number around the max (i.e. takes it
           mod the max value) whereas for unsigned data types it saturates.
           Another possibility might have something to do with the fact that
           99999999 is negative for signed char and signed short. -emin
           \_ I see.  I just tried 65537 and I got the same result.  Same for
              gcc 2.95.4 on soda also.
              \_ Try 65535.
                 \_ Same result.  But in this case, not complaining about the
                    'c' line makes sense because the comparison is not always
                    1.
        \_ from gcc 2.95.2 on sparc:
   % gcc -o foo foo.c
   foo.c: In function `main':
   foo.c:7: warning: comparison is always true due to limited range of data type
   foo.c:9: warning: comparison is always true due to limited range of data type
           try b < 127 and d < 32677
           --jon
        \_ Arrr!
           \_ Avast!
2003/9/18-19 [Computer/SW/Languages/Java, Computer/SW/Languages/C_Cplusplus] UID:10248 Activity:low
9/18    I have an embedded C++ application that passes around a lot of
        68-byte structs-- the struct is a wrapper around a binary message,
        and just about every function call includes one of them (usually
        passed by copy).  Today I changed the struct into a class which
        contains an empty Constructor/Destructor, and Configure() method
        which initializes every field.  Basically nothing else was changed:
        the 68-byte struct became a 72-byte object.  No inheritance, no
        virtual functions, everything is allocated on the stack.  My test
        suite is taking 300% longer to run, even with -O3.  Any ideas
        about what might be causing this?  I'm going to look into gprof,
        but if there are any hints and tips I'd like to hear them.  Thanks.
        \_ WAG: From your description, I gather you changed the definition
           from: struct Foo { ... }; to: class Foo { ... };
           Try changing "class" back to "struct" and see if that changes
           anything.
           \_ It does-- it cuts the running time by 2/3.  I've got 2
              parallel (except for the class stuff) directories and I'm
              running the tests side by side.
              \_ Well, are you passing these structs by value?  Are you
                 constructing and deconstructing tons and tons of classes
                 now?  Calling all those empty constructors and deconstructors
                 can get quite expensive.  Also do you have RTTI turned on?
                 That could explain the extra bytes,
                 \_ I don't have RTTI on explicitly (how would I check?),
                    and I'm not using any template stuff.  The compiler is
                    gcc 3.2.  Is there a way to optimize the (de|con)structor
                    calls to nothing?  I had figured that -O2 would take
                    care of that for me.  Also, I think that extra 4 bytes
                    is just a pointer to the dispatch table, which is
                    completely expected. --op
                    \_ If you have no virtual functions you don't have a
                       dispatch table, and you shouldn't have a pointer.
                       Trust me when your basic math objects are classes
                       and you have umpty millions of them, doubling the
                       size for a dispatch pointer would be really annoying.
                       \_ Aaah!  You're totally right.  Out of habit I had
                          put "virtual ~Foo() { };".  I removed the virtual
                          and the code is now about 5-10% *faster* than the
                          struct version.  Thank you thank you thank you.
              \_ Two more suggestions: Did you define Configure() in the
                 header file? If so, move it to the implementation file
                 and see if that makes a difference. Also, try compiling
                 with -Os, which optimizes for size (at least on my
                 gcc).          - struct guy
                 \_ Configure is defined in the .cc file; I'll give -Os
                    a shot now.
                    \_ Try swapping the the definition of the ctor/dtor
                       and Configure from .cc to .h or vice-versa.
        \_ Why did you change working code in the first place?  That's where
           your real problem is.
           \_ Obviously so he could put C/C++ on his resume!
2003/9/17 [Computer/SW/Languages/C_Cplusplus] UID:10218 Activity:nil
9/16    I manage the Engineering Department at a software company in
        Southern California. We have openings for several senior level
        developers. C/C++ required, MFC and Qt experience a plus. Send
        resumes to rjchu@hightowersoftware.com - I'll be out of town this
        week and doing call backs next week based on the resumes I get.
        \_ There is no such thing as C/C++.  Pick one or pick both.
           \_ C/C++ means you should know one or both. -!op
           \_ this guy never even has seen a job posting
              \_ I have.  It annoys me when people say "C/C++" as if they're
                 the same thing.  It's marketing-speak.
                 \_ No, you're being a nerd.  The languages are close enough
                    to not matter.  They want someone with C/C++ as opposed to
                    LISP or Fortran.  You'd prefer you had 15+ years of C and
                    no C++ and didn't get a call because they hired someone
                    with no C and 2 years of C++?  *That* would be stupid on
                    their part.
                    \_ c and c++ are, to program in, not very close at all.
                       a more technical person probably wouldn't be caught dead
                       saying 'c/c++', but i agree it's kind of silly to
                       belabor this point.
                       \_ It's a job posting.  The candidate is supposed to be
                          smart enough to be able to read a job posting without
                          flipping out.  Anyone bothered by a C/C++ listing so
                          much is way too anal to work in most places.  A job
                          posting is just a vague wish list of 'stuff' they
                          think might be nice for someone to know to some
                          degree or another so candidates can self-disqualify.
                          Stupid is when some marketing guy keeps applying to
                          all of the perl and java jobs at my company.  Zero
                          programming experience and not much marketing but is
                          applying for 3-5+ year experience required jobs.
                          *That* is stupid.  When we did open a marketing job
                          he wasn't considered due to previous stupidity.
                    \_ Yes, it would be stupid on their part, and it's
                       irrelevant.  If they don't care if it's C or C++, then
                       just say, "C and/or C++".  Is that so hard?  And the
                       languages aren't /that/ close; if you're writing C++
                       code that looks like C... well... <shudder>
                       \_ You're still being nerdy.  It's close enough for
                          most places and a lot of people who know one also
                          know the other.  "C/C++" is just shorthand for your
                          "C and/or C++".  Just chill and put down the Strunk
                          and White.  I'm glad to see people posting real jobs
                          here.  You shouldn't abuse them for it.  Don't bite
                          the hand.
                       \_ So if there's another job posting saying
                          "Assembly/C required", are you going to complain that
                          there's no such thing as Assembly/C too?  If you
                          think that manager is silly, don't apply.  I don't
                          complain about C/C++.  I only complained about job
                          postings saying "10yrs of NT programming required"
                          back in 1998.
        \_ Qt = cutie?
           \_ it's from a company called trolltech. you'd like it, obviously
              \_ I don't think that's trolling, just a newbie
2003/9/11-12 [Computer/SW/Languages/C_Cplusplus] UID:10155 Activity:nil
9/11    I am looking for a program that can make a flow chart out of
        C code. Is there anything opensource, or does Borland or MS C
        coding environment have anything that could do this?
        \_ man cflow. See cflow run. Run cflow, run!
2003/9/10 [Computer/SW/Languages/C_Cplusplus] UID:29529 Activity:nil
9/10    Stupid question: how do I reference a C callback?
        int mycompare(void const *a, void const *b) { ... }
        qsort(msg, sizeof(Msg), numMsgs, mycompare);
        I get
        "Type error in argument 4 to `qsort'; calling convention mismatch."
        \_ There's nothing wrong in the you reference it.  However, you should
           make the mycompare() prototype match exactly with what qsort() wants
           in its prototype.  Exactly what it wants depends on your machine
           and your compiler.  Check the .h file that you're including.
           \_ Yeah, I just realized that it compiles w/ gcc... I have some
              problems, apparently. --op
2003/8/29-2004/2/14 [Computer/SW/Languages/C_Cplusplus] UID:12260 Activity:nil
2/13    Where can I get c macro specifications? What keywords to look in
        google?
        \_ You might also want to find a good book on the specification of
           English, so you don't have to look like an ignorant tool asking
           a simple C question.
        \_ what do you want to know?  There's the C language spec that you
           can buy from ANSI.  You can ask on the comp.lang.c FAQ.  You can
           buy K&R.  Or you can see:
           http://www.lns.cornell.edu/public/COMP/info/egcs/cpp/cpp_toc.html
           \_ you can also get a cheap copy of the standard by buying the now
              out-of-print book "annotated c standard" or something like that,
              by herbert schildt. just read the left pages and ignore all the
              crap he spews on the right pages. how you find used copies of
              books is up to you.
2003/8/23 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Java] UID:29445 Activity:nil
8/22    http://www.wired.com/news/conflict/0,2100,60144-2,00.html
        Total crap.
        \_ 1. Post the first page, not the second.
           2. That sucks.
           3. This wouldn't have happened if he were handsome.
           \_ yes. yes. no.
        \_ Look at the mug on this kid!  I don't know if he should be let go
           out of sympathy or locked away so no one else ever has to see him
           again!  http://www.savebrian.org/media.html
2003/8/15-16 [Computer/SW/Languages/C_Cplusplus] UID:29352 Activity:kinda low
8/15    Are there any standard best practices for "faking" namespaces in C?
        Right now I'm prefixing my function names with "xb_"; is there a
        better way?  Please explain if so.  Thanks
        \_ you know if you declare a function as static, it has file scope
           \_ sorry, yes.  The prefix is not so much a namespace as a module
              identifier... so I have stuff like p_ for the parser, etc.
              The problem is that I'm moving C++ stuff to C so that it can
              be used by 1) non-OO types in my group and 2) a certain C-only
              toolkit (don't ask).
              \_ perl
2003/8/15-16 [Computer/SW/Languages/C_Cplusplus] UID:29350 Activity:moderate
8/14    any spreadsheet programs that can be interacted with via command line?
        e.g. excellike -e '$a4$b=44; printf "g65"'
        \- helo possible emacs wi/gnudoit ok tnx --psb
           \_ is there anything emacs *cant* do?
             \_ give you an easy-to-use intuitive interface. -ali
                \- i think the learning curve for emacs is pretty
                   reasonable. you can get started ithout learning how to
                   write a major-mode. you just need C-npfb, C-xC-f C-xC-c
                   and 5 or 6 other things. Also that teachkeys options
                   makes things easier. --psb
                   \_ teachkeys??
2003/8/14-16 [Computer/SW/Languages/C_Cplusplus] UID:29347 Activity:low
8/14    Is there a libc function that returns a count of the occurences
        of char c in string s, instead of the first index?  Thanks
        \_ No, but really: i = 0; st = s; while (st = strchr(st,c)) {i++;st++;}
          \_ why strchr instead of just directly accessing the string as an
             array?
             \_ No particular reason.
                i = 0; st = s; while (st) { if (*st++ == c) i++; }
             \_ poignant irony. you use strchr to prevent the bug the above
                code suffers from. also, you should use for loops. it'll be
                more readable. -ali
                \_ ^(st)^(st && *st)
2003/8/11-12 [Computer/SW/Languages/C_Cplusplus, Politics/Domestic/California] UID:29306 Activity:very high
8/10    Did anyone know Georgy Russell (CS c/o '99)? He's running for governor.
        \_ you are aware that Georgy's a she, right?
           \_ Does it matter?  -!op
              \_ well, if the op is looking for people who know her, yes, it
                 does.
                 \_ Not really.  The people who know her would know she's a
                    she, would they not?
        \_ So's Gary Coleman, big deal, what's your point.
           \_ Questions don't have points, they are inquiries... if someone
              was a classmate of his, they might say "Ya, the dude was a big
              dork, I couldn't stand him." or "he was always stepping outside
              of soda to smoke doobies."
              \_ Or they could be asking a question to call attention to
                 something.  You might also want to look up "rhetorical
                 question".  I deserve a fucking medal for being so polite to
                 you, this being the motd and all....
                 question".
              \_ I'm with ya, friend!  --motd grammarian #1 Fan
        \_ If he wins will he accept millions every year from the Computer
           Scientists Union to keep pushing their part of the budget up while
           everything else goes down?
           doing the heroine look. I bumped into her at a bar/club in SF (near
        \_ fyi: http://www.georgyforgov.com
           \_ What's the "heroine look"?
           \_ I read it last week.  She isn't quite joking, yet she isn't
              serious either.  What's she trying to do with the website?
        \_ Oh shit, I know who she is. I took several classes with her. I
           remember her name as Georgina. She was kind of cute, then started
           doing the heroin look. I bumped into her at a bar/club in SF (near
           the baseball stadium) once. She was also my reader for CS162.
           \_ "I think I'll look like a heroin addict today." fuck off.
           \_ I'll vote for her if she stops using pine.
           \_ What's the "heroin look"?
              \_ Too thin.  Underfed looking.  Pale.  Gaunt.  Boney.  Sickly.
                 \_ So you knew her too?
                    \_ nope.  I've seen the type.  It's common among young
                       women with self worth issues.
           \_ [ motdspellingd was here ]
        \_ She's cute! And EECS? Got my vote!
           \_ Your vote went easy.  There's nothing on her site about bjs for
              eecs votes.
        \_ From her website: 630r6y == G0\/3R|\|0R. no joke.
           \_ I hope she didn't dump $3500 on this.  The state will just
              spend it on something stupid.
              \_ she's raising money by selling underwear on ebay.
                 \_ new or used?
        \_ Hell, anyone who puts big, ugly Simpsons graphics in her .plan
           can't be all bad.
           \_ And she logs in to soda while she's at work-- c'mon, folks,
              she's _got_ to be our candidate.
              \_ So does everyone else here.
                 \_ ...and none of the rest of you are running for gov.
                    Ergo, she really represents us.
                    \_ Dear god man, did you read her platform?  She is far
                       too liberal.
                       \_ "Ergo" probably is, too.  Remember we're not all
                          60 hour/week alumni.  Some people on the motd are
                          students who haven't yet reached political maturity.
                          Things like legal pot seem important to them.
                    \_ There's almost no one on here that could represent "us".
                       Why?  Because there is no "us".  Maybe you've noticed a
                       few times here and there where there were some minor
                       political disagreements on the motd?  In what way does
                       she represent "us"?  Ergo, et al, etcetera, cum laude.
                       \_ "Ergo" is the only word I remember from that dumb
                          Architect monologue.
        \_ Anyone at Veritas know her?
2003/8/6-7 [Computer/SW/Languages/C_Cplusplus, Computer/HW/Memory] UID:29256 Activity:low
8/6     In C++, if I need to keep an STL vector around (because it's a field in a
        class I still need) but would like to minimize its memory usage, how do
        I do it?  resize(0), clear(), reserve(0), or something else??  Thanks.
        \_ none of those will deallocate already-allocated memory. use the
           "swap trick": assuming your existing field is f, do
           vector<foo>(f).swap(f). Or since you want just an empty vector
           apparently, vector<foo>().swap(f) will suffice. -jl
2003/7/29-30 [Computer/SW/Languages/C_Cplusplus] UID:29171 Activity:high
7/29    I want to zero-initialize an array of somewhat large structs.
        What's the best, most portable way to do so?  C++, embedded
        systems, stack-based array. TIA.
        \_ memset()?
        \_ the best way is probably to have a brace initializer
           that initializes the first struct explicitly (to all 0's).
           the rest of them will then be default initialized (to all 0's).
           this is also most portable because it will take into account
           weird systems, where e.g., the null pointer is not
           internally represented by all-bits-zero. -jl
           \_ do you mean MyStruct array[100] = { }; or
              MyStruct array[100]; array[0] = { }; ?
              \_ the former, though I meant you should have something
                 in between the braces to initialize the first element.
                 actually, gcc seems to accept just the braces, but
                 looking at the grammar, this appears not to be legal.
                 someone feel free to clarify this point. also note that
                 your latter option is assignment, not initialization. -jl
                 \_ It's legal as written -- an empty initializer list is
                    explicitly allowed.  --mconst
                    \_ reference? section 6.5.7 of the c standard doesn't
                        appear to mention any such thing, nor does the
                        grammar.
                        \_ The original poster asked about C++; the C++
                           standard allows it (8.5, paragraph 1).  It's
                           not allowed in C.  --mconst
                        \_ C++
                          \_ not portable
                             \_ Yes, portable.
        \_ do you mean all-bits-zero or each field in each struct assigned
           to zero?  If the former, why not use memset?
           \_ Sorry, I'm not that great at this-- is there a difference
              b/w all bits zero and all fields zero?  I really just want
              to initialize it to something "non-garbage" to distinguish
              between a struct that's been written to and one that has not
              been.  Thanks
              \_ Yes.  null pointers are not necessarily all-bits-zero.
                 floating point numbers have two representations for the
                 value 0 (although one of them is all-bits-zero).
              \_ they are the same in c++. 0 is guaranteed to convert to
                 the null pointer [conv.ptr].
                 \_ To be pedantic, any constant integer expression which
                    evaluates to 0 is guaranteed to convert to the null pointer
                    (say, (1-1) for example).
2003/7/12-13 [Computer/SW/Languages/C_Cplusplus] UID:29015 Activity:kinda low
7/11    Why does rlogin open two connections?  How does the server tell the
        client to listen and associate the "backwards" [S->C] connection with
        the initial connection [C->S]  ???
        C->S foo.978      bar.shell    49640      0 24820      0 ESTABLISHED
        S->C foo.977      bar.975      49640      0 24820      0 ESTABLISHED
        \_ One is the KVND listening in on your unencrypted connection.
           \- hello rlogin uses out of band signaling. read the rfc
              or one of the stevens book or UTSL or mail me if you think
              i might not dislike you. --psb
              \_ You think the KVND is limited by your puny and pathetic RFC?
                 For reasons of their own they've not yet pointed their orbital
                 mind control lasers in your direction, but oh, soon, very
                 soon now, my friend.
2003/7/6-7 [Computer/SW/Languages/C_Cplusplus] UID:28939 Activity:high
7/5     Besides method lookup of non-virtual methods, how is C++ considered
        slower than pure C?  The follow-up question: why hasn't C++ or
        another OO language moved into usage in kernels and drivers?
        \_ Larger standard library + linkers which link everything =
        \_ You probably mean "Besides method lookup of virtual methods".
           large code = poor cache performance.
        \_ OO == Obscene Overhead.  Lack of Language Maturity vs featurebloat
        \_ Non-virtual methods are as fast to dispatch as c functions. OO
           languages have been used in driver implementation: NeXT drivers
           could be written in Objective-C. Mac OS X uses a subset of C++,
           Embedded C++, for driver implementation.
           \_ So are there other areas of serious speed decreases besides
              method lookup?
              \_ I don't think virtual methods cause serious speed decreases
                 (the cost of looking up a method in the vtable is pretty
                 small). Templates and Exceptions have their potential gotchas.
                 See:
                        http://www.caravan.net/ec2plus/rationale.html
                        http://www.caravan.net/ec2plus/question.html
        \_ Linux is writen in C so C must RULE!
        \_ Only in the last year or two have we had compilers that actually
           implement the full C++ standard (okay, only one does--Comeau C++ with
           the EDG front end).
           \_ Not really a valid point; plenty of software projects use /
              have used C++ in its present / previous incarnations.
              \_ True, but the standard was evolving pre-1997.  Hence people
                 tended to use C++ conservatively (which lost a lot of the
                 benefits of the languague).  Also, the comment below about C++
                 sucking is pretty much the same thing.
        \_ Wasn't BeOS kernel written in C++?
           \_ Where's BeOS now?
              \_ Isn't Windows all C++ now?
        \_ Because the major kernels in use are over a decade old, and
           C++ really sucked then.  Completely new kernels rarely happen.
           \_ There's only one kernel!  Or well, there's the odd numbered and
              even numbered and then there's the -AC branch and maybe you
              put the SMP and thread/locking patches in and oh no, now you've
              gone ahead and done it!
                \_ Serves you right for not using '1337 GN00 HURD!
                   \_ Actually, I did.  It was a bitch to scrape off the drive.
                        \_ That is the "viral nature" of GPL software. - BillG
        \_ From what I understand, it's easier to be a moron with C++, but
           the raw performance issue is negligible for an experienced
           development team.
2003/6/26-27 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Compilers] UID:28847 Activity:moderate
6/26    What's a "constant function" in C?  I ran across this term in the gcc
        man page.  Thanks.
        \_ look at the info page. const functions are a gcc extension. gcc
           assumes the function has no side effects and subjects it to
           common subexpression elimination, for example when you call it
           in a loop. -ali
2003/6/25-26 [Computer/SW/Languages/C_Cplusplus] UID:28835 Activity:moderate
6/25    Can anyone recommend agencies for temp/contract programming work
        (Java, C/C++)? I prefer LA area, but Bay Area is good too.
        Thanks.  -ciyer
        \_ Taos?
        \_ Mindsource, http://vitrixinc.com, modisIT?  --chris
2003/5/13-15 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Java] UID:28427 Activity:high
5/13    Stupid C++ question but I can't get it to compile:
        struct MyStruct {};
        class Super {
        public:
          virtual void foo (MyStruct str, int* bar) = 0 {}
          virtual void foo (MyStruct str, unsigned int* bar) {
                        return foo(str, reinterpret_cast<int*>(bar)); }
        }

        class Sub : public Super {
        public:
          void foo (MyStruct str, int* bar) {}
        }

        Sub implements foo for a regular int, but should use Super's foo
        for unsigned int.  But whenever I compile I get errors about
        "invalid conversion from `unsigned int*' to `int*'" from code that
        uses an instance of Sub.  Help?
        \_ is foo virtual?
           \_ sorry, yes-- the first foo is virtual, the second is not (though
              I've tried making the 2nd virtual as well.)
        \_ I've put an explanation in ~mconst/pub/overriding-overloading;
           let me know if that answers your question.  --mconst
           \_ I had to go look it up to make sure, but your answer omits the
              using delcaration.  One solution is to add one line:
              class Sub : public Super
              {
                using Super::foo; //imports *all* overloads
                foo (MyStruct struct, int* bar);
              }
              The standard dictates that if you have the same signature from a
              using declaration and a member declaration, the member declaration
              wins. -emarkp
              \_ You're right, that is nicer; I've fixed my explanation.
                 (Unfortunately, though, it doesn't work with gcc 2.95 or
                 with Visual Studio .NET.)  --mconst
                 \_ It worked with VS .NET 2003 (7.1).  I'm not surprised if it
                    didn't work with 2002 (7.0).  The conformance is nearly
                    complete (missing exception specifications and export IIRC).
                    -emarkp
        \_ You must be explicit with each overload.  C++ rules are that if you
           hide one function, you hide *all* overloads.  Hence foo(Mystruct,
           unsigned int*) is not visible in class Sub.  See
           http://csua.org/u/ec6 -- look for "Q55" -emarkp
        \_ thanks for the helpful answers; I tried the using clause but
           didn't get instant results; this is targetted to a platform
           with a rather old version of gcc so I'm just going to suck it
           up and copy-paste into the subclasses.  Thanks again. -op
2003/5/10 [Computer/SW/Languages/C_Cplusplus] UID:28396 Activity:high
5/9     What are some reasons that would cause malloc to cause a segmentation
        fault rather than just returning NULL? I'm getting a seg fault
        trying to malloc some float**'s.
        \_ typically you have some other pointer bug that overwrote/corrupted
           malloc's bookkeeping data, causing it to segfault.
                \_ what sort of other pointer bugs?
2003/5/6-7 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Python] UID:28355 Activity:low
5/6     How difficult is it to write a python wrapper around a small C++
        class?  Any references would be appreciated, thank you.
        \_ Pretty easy.  If you use the simplified wrapper and
           interface generator (http://www.swig.org you can use the same
           C++ code from python, guile, tcl, perl, etc.
2003/5/4-6 [Computer/SW/Languages/C_Cplusplus] UID:28326 Activity:high
5/4     How reliable is <DEAD>cal.berkeley.edu<DEAD>? I'm wondering whether to use
        them as a permanent email alias.
        \_ I started using this around december as an alias (so far only to
           my csua account) and havent had any problems. I've experienced a
           slightly longer delay on average when sending mail to this as
           opposed to my csua account direcly (on the order of 3 minutes)
           ... but never any downtime as far as I know.
        \_ I've been using it since it first started. They had some
           problems initially but it has been pretty reliable for the
           last several months.
        \_ It's really cool!  It's a C-64 with tcp/ip loaded up from a 1514
           using a serial/ethernet converter!  All email is stored is ram
           stored and directly sent to the next hop so you don't have to worry
           about waiting for your mail to hit the second 1514 drive.  I'd
           trust it with my life!  Although sometimes they take it offline
           after hours to play any number of C-64 classics but that's only
           fair.
                \_ hi dork!
           \_ WooHoo! Who's up for a game of M.U.L.E.?
              \_ I'm partial to space taxi! (I have vice on my pc and play
                 these things all the time).
        \_ I've been using it since it first started. They had some
           problems initially but it has been pretty reliable for the
           last several months.
2003/4/27-28 [Computer/SW/Languages/C_Cplusplus] UID:28238 Activity:kinda low
4/28    Too many political trolls, so here's a computer one:
        Ok... how did sodans/calgrads start up on learning COM/MFC?
        Learning things like VxWorks, RogueWave and J2EE was pretty easy
        given my Cal background, but Win32 has always eluded me. MFC looks
        big an hairy, and COM doesn't seem too much friendlier. That said,
        C# looks to be pretty easy to pick up... although I'd be more
        interested in learning to write things like WinAmp and Win32 Games
        for fun.
        \_ I have used a lot of open-source software on Windows platform.
           From my impression, most of the stuff is written WITHOUT
           using MFC at all.  The general consesus is that MFC is to bloated
           to do anything useful.  Instead, these guys tend to put things
           together using C and Win32 API calls.
           \_ MFC isn't bloated, it simply sucks.  At best it's schizoid, and
              often you have to go down to the C API to do anything anyway.
              Use wxWindows instead, and you also get cross-platform code.
        \_ COM sucks.  Try Qt if you want to do Windows stuff.
           \_ Qt sucks.
              \_ Qt R00lZ0rz; u r n07 37337.
        \_ C# is easy.  It's also easy to get to the point where you want to
           beat your head against the wall until bloody.  The libraries are the
           strong point, but they're woefully underspecified.  (Would it hurt MS
           too much to tell us what the return value is on failure?)
2003/4/23-24 [Computer/SW/Languages/C_Cplusplus] UID:28204 Activity:very high
4/23    Does google analyze people's search behavior and which link they
        click in order to determine which link should come up first?  Like
        if a lot of people search for C++ STL library and always click on
        the third link first, then in the future the third link will move
        up and become the first link.  Does that sort of thing happen?
        \_ does their description of PageRank help any?  I think it is
           public knowledge (they wrote about it).  It is mainly based on
           the way the web is structured and not on the behavior of google
           users.
        \_ Yes, by slamming a particular link in google you can directly
           changing your pr0n site's ranking.  Yup, sure.
           change your pr0n site's ranking.  Yup, sure.
2003/4/22-23 [Computer/SW/Languages/C_Cplusplus] UID:28189 Activity:insanely high
4/22    Anyone know a good link that explains all of C++'s use of the
        keyword mconst?
        \_ http://www.parashift.com/c++-faq-lite
           Search for const in the text box.
           Search for mconst in the text box.
           \- perfection
              \_ The real PSB would know this already.  Wouldn't he?
                 \_ who the hell said i was psb. i'm not. -!psb
                    \_ the \- is a psb thing.
                       \_ only if tailed with "ok tnx." and the spacing has
                          to be foobared.
                          \_ The psb shall do as He pleases!  --psb #1 Fan
        \_ we haven't had a good C++ discussion in a while.  It's time to
           revisit.  Anybody use C++ in a truly object oriented manner?  Does
           true OO even exist outside of the some lame-ass textbook example
           on how the truck class is inherited from the automobile class?
           Every C++ prog I've seen is about encapsulating data (foo->bar = 1)
           and doing function calls (foo->func(1)).  The latest C spec allows
           you to do both.  So what exactly is the point of OO?
                \_ inheritance, virtual funcitons, templates (not really OO)
                   all make life a lot easier.
                        \_ inheritance makes life EASIER!?!
                           have you ever been involved in a
                           big C++ project?
                           \_ my personal, limited experience told me that
                              inheritance is not bad, but multiple-
                              inheritance is pain in the butt (i.e at least
                              our company never managed to used it properly
                              enough to be useful IN THE LONG RUN)
                           \_ He probably knows someone who took a class from
                              BH.  Does that count?
                           \_ yes and yes.  Yes, inheritance can be a headache
                              if used poorly, but so can everything.  Used
                              well, inheritance is a godsend.
                           \_ My current job is a scientific application with a
                              few 100K lines of code.  Fully C++.  Yes,
                              inheritance makes life easier.
                              \_ It's probably a matter of opinion.  But
                                 generally, use composition over
                                 inheritance.
                                 \_ I am so glad I don't work with you.
                                    \_ how do you know you don't?
                                 \_ Are you a total idiot?  Use the right tool
                                    for the right job.
           \_ i think you should read stroustrup 3rd ed and go argue on
              comp.std.c++
2003/4/19-20 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Perl] UID:28170 Activity:high
4/19    What's the closest thing Scheme has to a good standard library and a
        standard interpreter?
        \_ obUsePerl
           \_ Perl is a slow, broken mess.
           \_ there's a reason I like Scheme, and that reason is exactly why
              I can't stand Perl.
              \_ and that is?  If you say consistency I will laugh.
                 \_ a simple, elegant syntax.  and then there are first-class
                    procedures, first-class continuations, proper closures,
                    hygienic macros, ...
                    \_ i would rather read machine code than scheme
                    \_ Oh please.  The macros in CLisp and Scheme are a
                       nightmare.
                       \_ There is no better way to have general macros.
                       \_ ok, what's a language with a better macro system?
                          \_ I'll give you two: make, ant
                             \_ make and ant do not have a macro system.
        \_ r5rs
           \_ R5RS is the language standard.  It does not specify a standard
              library, and it's not an interpreter.
        \_ Is this for BH's project where the homeless guy gloms on to you
           until you get to campus and the campus police object beats him off?
        \_ /usr/ports/lang/scm
2003/4/14-15 [Computer/SW/SpamAssassin, Computer/SW/Languages/C_Cplusplus] UID:28123 Activity:insanely high
4/14    procmail question: All mail for http://domain.org goes through my .procmailrc
        file, and I'm forwarding @domain.org addresses to real "old"
        addresses.  If a message is sent to both henry@domain.org and
        kathy@domain.org, it looks like it reaches henry twice, and doesn't
        get to kathy at all. How can I overcome this?  It this beyond the
        scope of procmail?

                :0
                * ^TOhenry@domain.org
                ! henry@oldaddress.com

                :0
                * ^TOkathy@domain.org
                ! kathy@oldaddress.com
        \_ this can be solved with procmail but you need to learn how
           to use its branching structures, like { } blocks and the 'c'
           and 'a' tags. it's not hard to do but you need to carefully
           read the 'procmailrc' and 'procmailex' man pages. --aaron
           \_ Specifically, you need to replace ":0" with ":0 c" on every
              recipe.  Right now your recipes are telling procmail to
              deliver to henry, and then it's done.  "c" tells it to
              generate a carbon-copy to test with other recipes.
              \_ Rather, c tells procmail to pass a carbon copy to a fork
                 handling the current rule and continue.  Slight difference,
                 but good to be aware of. --scotsman
              \_ just adding c is going to cause henry to get two copies
                 of messages addressed to both; i think you need more.
                 this is one reason i love qmail -- administering an
                 email namespace is really easy and you don't need procmail.
                 \_ it's easy to maintain an email namespace in sendmail
                    also.  -tom
                    \_ for admins maybe. qmail makes it easy to grant
                       virtual domains to indiv users with no add'l setup.
                       \_ whereas in sendmail you might have to write a
                \_ If a message is "To: henry@domain.org, kathy@domain.org"
                   will two messages get processed by this .procmailrc?
                \_ Great I'll incorporate that, but: don't two duplicate
                   messages get processed by this .procmailrc?
                   without the "c" henry gets two messages, kathy gets zero.
                   with the "c" henry gets two and kathy gets two.
                          script that calls "cat"--how horrible!  -tom
                          \_ i understand your point but the qmail support
                             has a pretty rich feature set for this. accept
                             that qmail actually does some things well, i
                             know why you don't like it and i think you
                             have some valid points but not everyone
                             has your criteria.
                          \_ i don't understand and am curious.  How do i
                             grant control of a virtual domain to an
                             upriveleged user if i'm running sendmail?
                             \_ give them a file to write to, and write a
                                script to combine it with virtusertable. -tom
                                \_ Uuuuh, security???
                \_ quit being reasonable on the motd.  white power!
                   death to arabs!
        \_ The above rules are a recipe for disaster since they create
           a potential for a mail loop that's undetectable by sendmail and
           possibly other MTAs. A better recipe for forwarding mail to some
           other address would be:
           :0
           * ^TOkathy@domain.org
           * !^X-Loop: kathy@oldaddress.com
           | formail -A"X-Loop: kathy@oldaddress.com" | \
               $SENDMAIL -oi kathy@oldaddress.com
                \_ Thanks
        \_ Actually, I just found out that administering a domain's worth
           of email can't really be done correctly with a user's procmailrc.
           There needs to be an interface with the MTA in order to properly
           deal with multiple recipients, multiple messages, etc.
           Sorry to rack all yer brains. -OP
           \_ qmail is the *only* answer!  must...use.... qmail....argh! thump!
                --qmail fanatic
                \_ Do you have any recommendations for a excellent and
                   affordable web& email hosting company that uses qmail?
2003/4/10 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Compilers] UID:28060 Activity:high
4/9     Right now I have tons of snippets like
        sprintf(errmsg, "Error %d: invalid type %d at %d\n", 1, myType, time);
        QueueError(errmsg);
        Is it possible to define a macro to take an arbitrary # of arguments--
        #define ERROR(x) sprintf(globErrMsg, x); QueueError(globErrMsg);
        Or will the x in the macro just take everything up to the first comma?
        \_ #define ERR(args...) {sprintf(g_errMsg, args);QueueError(g_errMsg);}
        \_ Yes, if you use recent gcc or other C99-ish compilers, no for
           older ones.
        \_ A reliable method for doing this is to write a function that
           uses a va_list and vsnprintf:

           #include <stdarg.h>
           void Error (char *err, size_t sz, const char *fmt, ...) {
                va_list vl;
                if (err == null || sz <= 0)
                  return;
                memset(err,'\0',sz);
                va_start(vl,fmt);
                vsnprintf(err,sz,fmt,vl);
                va_end(vl);
                QueueError(err);
           }

           BTW, You should really avoid sprintf since it doesn't have a
           good way to check thesize of the input buffer.
           \_ thanks for the code, I'll give that a try today.  One question--
              this is a real-time application, so there are a few common stdio
              calls I use regularly and the rest are viewed warily.  Are there
              any non-constant performance implications for using vsnprintf?
              I can handle a +foo hit, but foo*strlen(err) might be pushing it.
              thanks.
           \_ that only matters if the content of your variables comes from
              input.
           \_ thanks for the code, I'll give that a try today.  One
              question-- this is a real-time application, so there are
              a few common stdio calls I use regularly and the rest
              are viewed warily.  Are there any non-constant
              performance implications for using vsnprintf? I can
              handle a +foo hit, but foo*strlen(err) might be pushing
              it. thanks.
                \_ vsnprintf calls vfprintf internally. In most cases
                   sprintf also calls vfprintf internally. The same
                   non-constant performance issues you may have with
                   your implementation of sprintf will most likely
                   apply to your implementation of vsnprintf.
           \_ that only matters if the content of your variables comes
              from input.
                \_ Program defensively.
2003/4/10 [Computer/SW/Languages/C_Cplusplus] UID:28058 Activity:high
4/9     Stupid question: as I grew older, I have found that straight
        ANSI C is one of most portable computer language out there.
        Why C is more portable than C++ ?
        \_ Because almost every single operating system in use today is
           written in C (not C++).
        \_ Compare K&R and Stroustrup.
                \_ why can't you answer him?
                   \_ You see, K&R is really thin, and Stroustrup is very big.
                      \_ what does that have to do with getting old?
                         \_ once you acknowledge it's not a troll you will
                            see the point he's making.
                            \_ you can make me understand, but you cannot
                               make me care.
        \_ Consider that there is no C++ compiler that supports all
           features of C++ according to the standard.  C is a much
           simpler, /smaller/ language.
           \_ Comeau C++ supports the full ISO C++ standard including export.
              VC++ 2003 will support nearly all of it.  I don't know where gcc
              stands right now.
        \_ and almost no C++ compiler supports modern (new ansi) C++
           fully. It's a zoo out there!
        \_ what is more portable than straight ansi c?
           \_ yo momma so fat, it's definitely not her
2003/4/2 [Computer/SW/Languages/C_Cplusplus] UID:27955 Activity:very high
4/2     Once again, any ideas where I can find 'Big C' as a Nokia ringtone?
        And yes, I live in a country where people mute their phones in
        public and in restaurants and don't pick them up in movie
        theaters and I know-to-behave-thank-you-I-just-want-a-ringtone
        because more people have nicer better newer phones here with the
        same rings and I don't feel like fumbling for mine every time
        someone else's goes off.  Thanks.  -John
        \_ If everyone mutes their phones in public where you live, how
           is telling your phone apart a problem?  And how is putting your
           phone on vibrate, like a decent human being, not a better
           solution to this?
           \_ "public" = restaurants and theaters and things.  Don't be a
               pedant.  And putting your phone on vibrate when it's lying
               halfway across a large test lab is not an option.  Why am
               I arguing with you anyway?  You're being a baboon.  All I
               asked for was a ringtone.  -John
               \_ ...which not one seems to have.  So we're bored at work
                  with nothing to do but make fun of you pointlessly.
                  There are worse things we could be doing. Come on, argue!
                  \_ No no no you're a baboon and I have no morals.  And
                     don't be bored, go look for a ringtone for me.  -John
                     \_ Just be glad I'm not hurling dung at you, as is
                        my instinct.
                \_ I respond well to being called a baboon, please
                   hold your breath while I attempt to help you out.
                   \_ He wasn't calling you a baboon, he was calling me
                      a baboon.  I'm going to start hurling dung at you, too.
        \_ This is morally inexcusable John.  The motd is ashamed of you.
           \_ I have no morals.  Yuck foo.  I just want my ringtone.  -John
        \_ How to installing new for pine ring tone?
           \_ 1: Making fun of people's English grammar errors is pretty
                 pathetic, since they probably speak your language much better
                 than you speak theirs.
              2: The common error is just "how to" instead of "how do I".
                 That is the way questions are formed in many languages.
                 You're just showing how ignorant you are.   -tom
                \_ Wow, for once I really disagree with tom. -tom#1fan
                \_ Actually, I've ceased believing that there are any actual
                   non-native speakers on soda.  The questions are always so
                   over the top that it's gotta be a native.
2003/3/25-26 [Computer/SW/Languages/C_Cplusplus] UID:27833 Activity:high
3/24    I have not been using C/C++ for the last 5 years.  I am wondering if
        there's something like the Perl De/Serializer for C/C++.
           \_ What about something like ResourceBundle in Java?
        \_ of course not. mabye you should take a civics class, you ignorant
           liberal stooge.
                \_ Problems with your self-esteem?  Mommy and daddy too mean?
                   \_ ignore him, his penis too smal, that must be it.
                        \_ what does any of this crap have to do with the OP's
                           question?
           \_ What about something like ResourceBundle in Java?
        \_ Take a look at the following:
           http://www.parashift.com/c++-faq-lite/serialization.html
           http://xparam.sourceforge.net/guide
2003/3/15 [Computer/SW/Languages/C_Cplusplus] UID:27702 Activity:very high
3/14    Are the fields stack-allocated structs initialized to zero? (C++)
        \_ Nope.  But, like C, you can always write MyStruct s = { };
           to declare a struct s and zero-initialize it.  --mconst
           \_ What is the difference between this and:
              memset(struct,'\0',sizeof(struct))
              I usually use memset, but I'd rather use something else
              that involves less typing if it accomplishes the same
              thing.
              \_ There's no difference at all, unless you're on a weird
                 machine that doesn't store zero values as all bits zero;
                 gcc compiles the two to the exact same code.  --mconst
                 \_ Thanks.
                 \_ it's not so weird for null pointers to be non-zero, is it?
                    uncommon, but not unheard of.
              \_ I believe memset will work with heap-alloc'ed memory
                 but "= { }" will not.  man bzero, it's a little bit
                 less typing.
                 \_ I'd use bzero, but it is deprecated on Linux and
                    other platforms.
                 \_ of course the "= { }" won't work on heap allocated memory,
                    because you can only initialize structures like that when
                    they're declared, and declared variables are stored on the
                    stack.
           \_ thanks, glad to know this now.
2003/3/14 [Computer/SW/Languages/C_Cplusplus] UID:27692 Activity:high
3/13    In C++, what is the type of the expression (01 << i)?
        Is it an int with all bits set to 0 save 1 at bit position i, or
        something weird and scary?
        \_ It's an int, just as you described.
           \_ thanks.
2003/2/21 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Editors/Emacs] UID:27472 Activity:nil
2/20    Another emacs question if you will. How can I get it to color
        code different syntax words if I'm editing a C file? Thanks.
        \_ Put "(global-font-lock-mode t)" in your ~/.emacs.  -- yuen
                \_ awesome. thanks.
2003/2/14-19 [Computer/SW/Compilers, Computer/SW/Languages/C_Cplusplus] UID:27419 Activity:low
2/14    Is there any way other than using "_asm" to access x86 registers as
        variables in C code compiled with MS C++ Compiler version 12 or 13?
        (In the BC++ for DOS, for example, I can use "_AX".)  I tried
        http://msdn.microsoft.com but couldn't find anything.  Thanks.  -- yuen
        \_ What is wrong with _asm, is it bad?
           \_ No, but I just want to do something like "if (_AX = 3) {...}".
              If I use "_asm" blocks I need multiple lines and a label. -- yuen
             \_Something seems fundamentally wrong with this kind of statement.
               Specifically,  mixing C and assembly that way just doesn't work.
               I really think you must load the AX register into a short
               variable, then test the contents of that variable. Otherwise
               you may not get what you intend.
               \_ Okay, I'll do that.  Thanks.  -- yuen
2003/2/12 [Computer/SW/Languages/C_Cplusplus] UID:27376 Activity:nil
2/11    I need a codename for a new project relating to space starting
        with the letter C.  Ideas?
        \_ "Project Codename".
        \_ "Project C-krit".
        \_ "Cassiopeia", "Cepheus", "Constellation"
        \_ "Columbia"
        \_ "Crash" "Catastrophe"
        \_ duh, "Cosmos".
           \_ he's fired, you're hired!
              \- "Butthead Astronomer"
        \_ Comet
        \_ cunt. oh wait, what kind of space...
        \_ "Cetec Astronomy"
2003/2/6-7 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Security] UID:27322 Activity:low
2/5     I picked up this year's Taxcut and it won't import last year's turbotax
        files. I'm gettign idiotic errors where it either wants to treat my
        TT file as a TC file and then reports a corrupt file or it looks for
        a TC named .T01 file when it's clearly a TT .tax file. I've played
        around with filenames and even looked at hex editing the binaries.  Is
        anyone else trying to do the same thing?  Is it working for you?
        \_ importing is highly over-rated.  Name, address, soc security, etc
           can be easily typed in.  The only other thing you need to worry
           about is carryover capital losses (stock).  It's more complicated
           if you run a small business and need schedule C.  But you probably
           don't run a business.
           \_ Hmm. Well that sucks.  Thanks for the info.
2003/2/5-6 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Java] UID:27308 Activity:high
2/5     In C, the typical way to generate random numbers in the range [0, N)
        is (int) ((double) rand() / ((double) RAND_MAX + 1) * N).  What
        guarantee is there that RAND_MAX + 1 does not overflow?
        \_ RAND_MAX is 32767.
           \_ RAND_MAX is guaranteed to be at LEAST 32767.
        \_ aren't your parentheses misplaced wrt N?
           \_ no.  You generate a floating value in the range [0, 1), multiply
              by N, and cast to int.
              \_ right. as written, it's generating [0,1) and dividing by N,
                 n'est-ce pas?
        \_ Note that you're casting RAND_MAX to a double.  Standard IEEE754 has
           54 bits of significand in a double.  That's typically more than
           anything a 32-bit machine has to offer.  However there is no
           guarantee against overflow.
           By the way, rand() is a crappy generator.  The method above leads to
           non-uniform probability distribution (some values will be twice as
           likely than the rest), etc.
                \_ so can you change the seed each time, based on prev #
                   and other factors to make it distribute more evenly?
                   \_ it doesn't matter what the seed is.  most implementations
                      of rand() just suck.
                      \_ understood.  care to suggest a better way of
                         generating random numbers?
                         \_ digitize johnson noise and take the least
                            signifigant bit?  i'll bet you could make
                            a box to do this for about a dollar in electronics.
                            I think there are chips that do this, or use
                            shot noise which is also white.
                            -naive physicist
                                \_ Actually, the best way would be to
                                   to take some radioactive material
                          \_ well even just C's "random" function is better than
                            "rand". look at "man 3 rand". i would try the /dev
                            random device but then that's not very portable
                                   and measure either the amount of
                                   decay or the interval between two
                                   decay events and use that as a
                                   basis for your random numbers.
                          \_ read from /dev/(u)random
                          \_ http://www.boost.org/libs/random/index.html
                          \_ well even just C's "random" function is better
                             than "rand". look at "man 3 rand". i would try
                             the /dev random device but then that's not very
                             portable
                                \_ It works on MacOS X, Solaris (8+),
                                   L1NUX, *BSD, how much more portability
                                   do you want?
        \_ (int) (drand48() * N);
2003/1/18-19 [Computer/SW/Languages/C_Cplusplus] UID:27139 Activity:very high
1/17    If I have "foo_bar_baz_struct_t *p, *q;", which of the following
        is better?
        1.      p = malloc(sizeof (foo_bar_baz_struct_t));
                memcpy(q, p, sizeof (foo_bar_baz_struct_t));
        2.      p = malloc(sizeof *p);
                memcpy(q, p, sizeof *p);
        Thanks.
        \_ 1 is far more obvious for me...
        \_ 2 is better if you think you are going to change
          what type of struct p points to frequently. 1 is
          the preferred way of coding for readability.
        \_ Well, I like 2.  It's more concise, and you can't screw up
           and put in the wrong type in the sizeof.
           \_ My vote is for #2 too. Also, I like *q = *p better than
              the memcpy. And no, for someone familiar with C, I don't
              see how the memcpy makes anything clearer.
              \_I don't think that they are necessarily the same in straight C.
              In C++ that may be equivalent. Also, shouldn't you be mallocing q?
              \_I don't think that they are necessarily the same in straight
                C. In C++ that may be equivalent. Also, shouldn't you be
                malloc'ing q?
                        \_ It seems so. Also, shouldn't OP be checking if
                           the pointer returned by malloc is NULL?
                \_ You are exactly backwards. -pld
                \_ you think wrong.  In C bar=foo does a shallow copy.
                  \_ Yes, we know this, but the question is does memcpy
                     do a shallow copy also? Somehow I think this is
                     wrong. From what I remember memcpy does a bit for bit
                     copy, which is very problematic once you get into things
                     like structs and classes. The two may not be equivalent,
                     and it certainly would come out different in the
                     object code.
                     \_ How do shallow and bit-for-bit differ? Very curious-pld
                       \_ It may or may not, it depends on what the struct
                       actually contains. That's the crux of the argument.
                       If the struct contains a class or class pointer(assuming
                       you are doing this in c++) you
                       run into all sorts of different behaviors.
                       \_ The proper answer is "they're identical"  -pld
                          \_ No they are not.  Shallow copy copies pointers,
                             deep copy copies objects also (potentially
                             using copy constructors, etc.)
                  \_ Is it possible that this is a Visual C++ extension for C?
                     Possibly, if they are on crack. You can do this in C++ by
                     defining your own operator= method.
2002/12/19-20 [Computer/SW/Languages/C_Cplusplus] UID:26853 Activity:low
12/18   For all you MacGuyver types out there ... I have a friend who
        wants to do C programming on his WinCE or Palm device (he has
        both).  Any suggestions for pure C/C++ environments that
        work on the PDA's (as in all development is on the PDA).
        \_ Run NetBSD on the WinCE device.  Use GCC.
        \_ Development Environment is free for WinCE (Pocket PC), and is just
           like visual c/c++.  See:
           http://www.microsoft.com/mobile/developer/downloads/ppcsdk2002.asp
2002/12/13-16 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Editors/Emacs] UID:26806 Activity:nil
12/13   how do I configure emacs to automatically untabify when save on
        c/c++/java (etc) files? but not all files... thx
        \_ Meta-X auto-untabify-on-save-CandClones
2002/12/9-10 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Perl] UID:26764 Activity:moderate
12/9    help, i can't seem to figure out how to get the group info for a given
        user from c.  In perl i'd just do @theuser=getpwnam USERNAME;
        $theuser[3] would be what i'm looking for.  How do i do this in c?
        \_ man getpwent
        \_ getpwnam()
2002/12/8-9 [Computer/SW/Languages/C_Cplusplus] UID:26749 Activity:high
12/8    I just got handed a large Visual Basic...thing...and I need to
        convert it to C++ fast.  Does anyone know of a good program that
        can do this in an automated fashion?  I STFW'd and was only able
        to come up with some REALLY expensive software.  Thank you for any
        assistance!
        \- contract someone unemployed? serious suggestion.
           \_ A good suggestion, but not within my power.
        \_ why do you need to do this?  if it ain't broke, don't fix it.
           \_ Standardization.  It's now Company Policy.  *shrug*
              \_ "Ok, no problem, we'll need 250 man days.  Do you want it
                  in 2-3 years or do you want to hire more people?"
        \_ Code costs ~$100 per debugged/tested line.  If you want some way to
           do it manually, run a metrics program and do the math on the real
           cost.  Otherwise, you'd probably do well to convince management
           that they need to buy this expensive tool you described.  They talk
           about this situation in "Rapid Development" by Steve McConnell,
           where management has fantasies of projects being completed in x
           days because they said so, but you would do well to dis-illusion
           them with the above math, and a copy of Rapid Development to back
           up your argument.  [formatd]
           \_ Huh.  That's sound advice.  Thank you!
2002/11/5 [Computer/SW/Languages/C_Cplusplus] UID:26409 Activity:high
11/4    I'm having a problem formatting inline elements in xsl-- I have to
        handle the situation where
        <school>I graduated from
          <link href="<DEAD>www.berkeley.edu"<DEAD>Cal</link> in 1998.
        </school>
        My current template is like this:
       <xsl:template match="school">
         <xsl:apply-templates/>
       </xsl:template>
        But the this causes the space after "Cal" to be ignored, rendering
        "I graduated from Calin 1998." (with Cal appropriately hyperlinked)
        How do I solve this?  -mjm
        \_ Don't know how well this would work, but you could try
            <xsl:preserve-space elements="school"/>
           That might be a little overzealous, though. -geordan
           \_ I tried that, no luck.  It seems like this would be a problem
              common to any inline element, but I haven't seen a good
              solution yet.  -mjm
        \_ You're seriously doing your resume in XML?  Trust Motd Wisdom on
           this: no one cares what format your resume is in.
           \_ The example was fictitious but representative.
           \_ You never heard of XML Resume? Let's you create text, html
              and pdf resumes w/ ease. Also, lets you create different
              resumes based on where you are applying (e.g. C vs. Java
              resume). -!mjm
              \_ It also allows you to demostrate that you know XML/XSLT
                 when applying for XSLT jobs.
                 \_ No one cares.  Your text only resume is going to a bimbo
                    in HR who doesn't know anything about anything and is only
                    scanning for keywords off a list.  Your resume is not the
                    place to demonstrate your madly kewl hx0r skillz.  As an
                    alum who has "been there, done that" in the job market and
           Not sure why it would make any difference.
                    has had no problems getting new and very high paying jobs
                    during a down economy I think I might be in a good position
                    to tell you this and be right.
                    \_ How high is very high? -alumnus looking for job.
        \_ My page comes up correct with the space and I use this:
           <xsl:template match="school">
                <a href="{@href}">
                <xsl:apply-templates/>
           </xsl:template>
           Not sure why it would make any difference; perhaps it's not
           the syntax but rather a bug in the transformer you use.
           \_ This will linkify the entire sentence, won't it?
              \_ Err...no, it only does so for the school element.
2002/10/17 [Computer/SW/Languages/C_Cplusplus] UID:26236 Activity:nil 72%like:26228
10.17   Primary language used:
        ocaml: .
        java: .
        c: ....
        c++:  .
        c#:   .
        perl: ....
        other:
        fortran77:
        fortan90/95/99/2000: .
        assembly: .
        English: .
        \_ How to learn good English?
           \_ Take CS9H.
        bourne shell: .
        pascal: .
        labview: .
        html: .
2002/10/17 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Perl] UID:26228 Activity:nil 72%like:26236
10.17   Primary language used:
        java: .
        c: ..
        c++:  .
        perl: .
        other:
2002/10/16-17 [Computer/SW/Languages/C_Cplusplus, Computer/HW/Memory] UID:26215 Activity:moderate
10/16   In C, What's the difference between offset_t and ptrdiff_t?  I used to
        use size_t for variables representing offsets, but now I think size_t
        might not be right.  Thanks.  --- yuen
        \_ I don't know for certain, but here's my thinking:
           ptrdiff_t is signed and should be sufficient to store the
           displacement between two items of the same type.  size_t (produced
           by sizeof) is unsigned and should be sufficient to store the
           size of a type.  offset_t (produced by offsetof) is unsigned (I
           think) and should be sufficient to store the offset of an element
           within a type.  Therefore, aside from the sign differences,
           the range of ptrdiff_t may be greater than that of size_t which
                                         \_ I take this back.  It makes
                                            no sense. (Not that the rest
                                            does.) --jameslin
           may be greater than that of offset_t.  Maybe you should ask on
           comp.lang.c. --jameslin
           \_ size_t is usually 32 bits, and is used to represent the size
              of objects or buffers and the like, off_t is used to represent
              offsets in files and is often 64bits.  Why does this matter
              though?  Outside the interfaces these are used in, there
              is no special meaning to them.
              \_ I see.  off_t (and offset_t on SunOS5) is for file offsets,
                 not memory offsets.  So I should use ptrdiff_t for memory
                 offsets then.  Thanks.  --- yuen
2002/10/4-5 [Computer/SW/Languages/C_Cplusplus] UID:26101 Activity:insanely high
10/4    Which of the following #endif comment in C is better?
        (a) #ifdef FOO
              ... foo code ...
            #else
              .... non-foo code ...
            #endif /* FOO */
        (b) #ifdef FOO
              ... foo code ...
            #else
              ... non-foo code ...
            #endif /* !FOO */
        Thanks.
        \_ a actually makes sense.
           \_ to normal people, but I'm sure that some 1337 l1nux d00d5 will
              like (b) better. (Trust me, I've seen stranger)
              \_ Ah, the GNU way.
                         \_ please learn to spell, its GN00 not GNU.
                            - 1337_5P34Kd
        \_ The first one is better, since !FOO is usually used to match
           a ifndef FOO.
        \_ I don't get the joke.....
           \_ Me either.  Some sort of ultra nerd thing I guess.
              \_ It's not a joke.  I'm trying to figure out how to write my
                 code.  Thanks for the responses so far.
                 \_ Uhm... ok.  You realise its the same code and only the
                    final comment is different by a single character?  Neither
                    way is "better".  Comments are there to make sense of your
                    code for others.  I don't think you need that comment at
                    all unless you work with monkeys in which case it won't
                    matter anyway.  Good luck!
                    \_ Yes, only the final comment differs by a single
                       character.  I should've mentioned that the code between
                       the #if and #else and between the #else and #endif is
                       usually pretty long, about 100 lines or so.  So I want
                       to see which comment makes the code more clear to
                       others.
                       \_ Oh.  In that case I'd use the first one.
                          \_ Okay.  Thanks.
        \_ A.  the #endif goes with the #if, not with the #else.  Otherwise,
           it'd be #endelse.
2002/8/25 [Computer/SW/Languages/C_Cplusplus] UID:25677 Activity:kinda low
8/24    What preprocessor is needed for man files that ends with suffix "x"?
        \_ rpcgen
           \_ this sounds funny because rpcgen generates C code rather than
              man page.
           \_ this is funny because rpcgen generates C code rather than
              input for nroff out of manpage files.
2002/8/8 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Compilers] UID:25522 Activity:high
8/8     Why do people declare functions as "static" all the time in C?
        \_ one of the reasons is that static makes the function local
           to the file.
           to the file.  Similar to a private method in C++ or java.
           \_ So that's just a linker issue? Preventing namespace collision?
              \_ that's one of the reasons.  There are probably more, but
                 that's why I like to use static in C.
        \_ Another is because some lame compilers barf if you declare a
           function that doesn't have a prototype unless it is static.
2002/8/7 [Computer/SW/Languages/Functional, Computer/SW/Languages/C_Cplusplus] UID:25509 Activity:low
8/5     What's a function pointer and when is it useful?
        \_ pointer to a function, useful for emulating C++-like functionality
           (inheritance,  vtables) and pretty efficient
           \_ not to mention things like signal handling ..
        \_ And the mess my 60c partner made of what was supposed to be a simple
           switch/case statement that he turned into an array of pointers to
           functions called based on some weird shit pulled from his addled
           little brain.  No it was not useful.  I killed him and fed him to
           the pigs.
        \_ have you taken 61a?  did you miss the part about higher-order
           functions?  ever use qsort or bsearch from stdlib.h?
        \_ For those of you who grew up learning OO oriented languages you
           can think of it as a primitive form of an interface. In general
           type of programming you should generally avoid it. If anyone
           remembers Xt programming you know why.
        \_ In languages like lisp, tcl, python, etc., you can pass a
           function as an argument.  For example, you can pass a comparison
           function to a sort routine as noted above.  In C you can't
           pass the function, but a pointer to the function which serves
           the same purpose.  As described above, you can use this to
           implement things that seem more like classes in C.  Take a look
           at http://soda.csua.berkeley.edu/~emin/source_code/red_black_tree
           to see an example.  -emin
2002/8/5-7 [Computer/SW/Languages/C_Cplusplus] UID:25503 Activity:very high
8/5     In ANSI C, assume a typedef of Foo for an UnsignedInt16 ,
        then assume that I declare a multiarray Foo foo[a][b] = {..}.
        How do I assign a pointer to foo? Do I do a Foo **bar?
        If Foo **bar then bar=foo doesn't seem to work.
        \_ References to an array name only decay to pointers for one
           level. So do bar = &foo[0].x
           \_ huh?  what the hell is x?
              \_ x is the first element of type Foo
              \_ x is someone slipping up with emacs.
        \_ This doesn't make any sense. A multidimensional array does
           not contain actual pointers to any of its elements, so there
           is nothing for bar to point at. If you do foo[0], this
           standard notation. Also, foo *bar can be assigned to bar = foo
           if foo is Foo[a]
           produced only a temporary pointer; getting the address of
           if foo is Foo foo[a].
           this is not a sensible thing to do.
           \_How so? Main has char **argv, and I can reference it using
           standard notation. Also, Foo *bar can be assigned to bar = foo
           if foo is Foo foo[a]. So why wouldn't there be an analogous
           expression for a pointer to a multidimensional array? If
           what you say is true, then is it impossible to reference a
           multiarray using a pointer? How would I go about passing
           multiarrays to functions then which would like to store a
           pointer to the multiarray?
           \_ your C-fu is lacking.  The declaration T foo[a][b] allocates a
              contiguous chunk of memory that's a*b*sizeof(T) bytes long.
              argv, on the other hand, is an array of pointers and is not
                                             \_ sorry, I misspoke.  I meant
                                                to say that it is a pointer
                                                to an array of pointers.
              a true multidimensional array.  The fact that you can
              dereference elements to both using [] operators is syntactic
              convenience.  Go read the comp.lang.C FAQ, section 6 in
              particular:
                http://www.eskimo.com/~scs/C-faq/top.html
                \_Yes, I know that foo[a][b] allocates a contiguous chunk of
                memory, so does foo[a]. What I have a problem with is the fact
                that foo[a] can decay into a pointer but not foo[a][b]. I
                read the FAQ, and I think essentially the problem is is that
                ANSI C provides no method of recursive pointer decay from
                a multiarray. I don't know why not, perhaps it has something
                to do with  compiler performance issues. So I suppose i
                the short answer is
                "no, it can't be done" and I solved the issue by dynamically
                allocating a multiarray using a pointer pointer.
                  \_ Why should foo[a][b] decay into a pointer?
              \_ Hmm, I learned C 12 years ago and I still find this section
                 of the FAQ very useful.
        \_ What you can do is Foo (*bar)[b]; bar = foo;
           \_ shouldn't that be: Foo (*bar)(b); bar = foo;
              \_ uh, he's not declaring a function pointer.
        \_ If the OP has their answer from the above would you please delete
           this thread.  I'm losing 1d4+1 sanity points everytime my eyes pass
           over this part of the motd.  thanks.
           \_ the first "1" in 1d4+1 is redundant.  unless you're using it as
              a placeholder, remove it, or you threaten a segfault in the rest
              of us.
              \_ No, that's how it's done.  When you publish your own game
                 system you can drop the "1" in front.  Until then you take
                 1d30+7 silliness points and are stunned 1d4+1 motd threads.
2002/7/30 [Computer/SW/Languages/C_Cplusplus] UID:25445 Activity:high
7/29    Is there a util to properly justify a unix text file to 80
        characters?  This isn't for the motd.  I just want something that
        will wrap words if need be, treat a double newline as a seperate
        paragraph, and leaves lines less than 80 chars alone
        \_ YES!  We did this as the second project in Hilfy's 60c class!!!
           I just *knew* the pseudo-latex format project had some use for
           someone somewhere!  We also had macro replacement including
           recursive macros that could replace other macros with parameters,
           etc, etc.  Do you also need code to detect if one non-directed
           graph (with variable node labels) is a sub-graph of another
           non-directed graph?  We did that, too.
        \_ fmt
        \_ "M-x fill-region" in emacs.  See Help for its various options.
           --- yuen
        \_ no.  (n.b. the op asked for "leave lines less than 80 chars
           alone."  actually i am fairly sure nothing will leave non-
           paragraph delineated less-than-80 characters lines alone.)
           \_ I really just want to be able to maintain the formatting
              on a block of text (lyrics / poetry, maybe others).  Any
              ideas?
              \_ learn roff.
2002/7/15-16 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Java] UID:25363 Activity:very high
7/14    Is there any viable way to make a career out of perl stuff?
        it seems that everywhere is J2EE, etc.
        \_ http://jobs.perl.org
           \_ how to get the foot into the door
                        -- old and inexperienced
              \_ Get a code portfolio together.  Get some perl gods to look
                 it over.  Send out en masse
        \_ Certainly. I work for a large e-commerce site, and our entire
           fufillment system is written in perl. (Sorry, no openings.)
           \_ I had no idea that people still boast about working at
              an e-commerce or b2bi company anymore.
              \_ What exactly is a "fufillment" system, anyway?
                \_ yer mom?
              \_ 1) he wasn't boasting, 2) he has a job, 3) he didn't say
                 anything about who or what his company is/does.  Get over it.
                 \_ 1) he WAS boasting. "I work for a large e-commerce site"
                    is bragging. Boasting is okay but at least have something
                    to boast about. 2) Unless he's a janitor, I don't
                    consider any position in an e-commerce company to be
                    a real job. 3) He works at an e-commerce company. You
                    can infer that it doesn't do anything. See
                    http://www.trilogy.com for details.
                    \_ You need to get a grip. He was just providing a picture
                       of how a decent number of jobs exist for the project.
                       \_ Uh, no. I was originally being facetious but someone
                          had a bug up their ass that they had to respond
                          with 3 points. So I did what any good old motder
                          does and respond with 3 sardonic points myself.
                          And no decent jobs exist for the project. The guy
                          even said that there weren't any openings.
                          \_ No you were originally being an asshole and still
                             are.  1 point.
                          \_ Are you the one who believes in getting
                             mythical "motd points"?
                          \_ Perhaps you ought to practice saying, "I'm
                             wrong."
                             \_ I'm C00L D00D cuz I do top-notch Perl
                                coding for a leading e-commerce site
                                which specializes in B2B integration
                                and extremely extensible e-solutions.
                                What do we make? Nothing. We specialize
                                in "mindshare". You guys need to get
                                a life. Or better yet, a REAL job for
                                once.
                                \_ Still an asshole.  Is that another point or
                                   do you not get double points for the same
                                   thing?  Just curious.
                                   \_ Aaaawwww. I'm soooo sorry I hurt your
                                      poor little feelings. Is there anything
                                      I can do to ease your pain?
                                      \_ Uh?  You're confused.  I don't see how
                                         anyone with the tiniest shred of brain
                                         material could think my feeling were
                                         involved in any way.  Fucking weirdo.
                                \_ thanks for answer my question... may
                                   i email you for further questions?
                                   please drop a note
                                                         --kngharv
                                   \_ Okay, kngharv. I'll give you some useful
                                     advice if you're actually willing to
                                     listen to it rather than just resorting
                                     to childish insults. If you want to
                                     learn Perl, that's fine. Just don't make
                                     an entire career out of it. And don't
                                     make the same mistake that many EE/CS
                                     grads here have made by joining these
                                     dot-coms/B2Bi/e-commerce companies
                                     thinking that there's some pot of gold
                                     at the end because most of them are just
                                     failing companies that don't really do
                                     anything substantive. And I can assure
                                     you that, if you choose to take this route,
                                     your skills will most certainly not
                                      \_ You're still presupposing that
                                         the poster was "boasting."  Sorry,
                                         but "I work for a large
                                         e-commerce site" doesn't quite
                                         qualify as "boasting."  Thanks for
                                         playing.
                                     be recognized. I know from working in
                                     industry that many employers look down
                                     on these types of NCG's as just purely
                                     incompetent gold-diggers. But it's your
                                     life so you decide what's right for you.
                                     \_ Wow!  Someone is *really* bitter about
                                        missing about on the easy money so many
                                        others here got in the last few years.
                                        May I suggest valium+therapy combo?
                                \_ No, I think the OP was just trying to
                                   be helpful by answering the original
                                   question.  You, on the other hand, seem
                                   to be freaking out.  Calm down, man.
                                   \_ No. My original response was that
                                      I found it surprising that people
                                      still boast about working at an
                                      e-commerce site. That was neither
                                      being an asshole or freaking out.
                                      I was just pointing out that this
                                      whole e-commerce thing is just part
                                      of a dead gold-rush and people
                                      should get back to reality. Of course,
                                      there's always somebody who gets so
                                      offended by this that he freaks and
                                      and feels the need to post a 3-point
                                      response.
                                      \_ Stop being a bitch.  Get a life.
                                                - yap
                                      \_ No one freaked but you.  You're just
                                         bitter you stayed with your $50k job
                                         the last 5 years while others were
                                         raking in more than twice that at fake
                                         companies and some of them even cashed
                                         in big time.  Now that things are
                                         settled out, those same folks are
                                         still making $90k or more while you're
                                         waiting for your next 1% COLA.  I'm
                                         really truly honestly sorry you chose
                                         poorly but ranting about it on the
                                         motd and bashing some shnook who
                                         merely mentioned on the side what his
                                         company does with perl is not a very
                                         endearing quality.  It was a once in a
                                         lifetime free money fest and you
                                         missed out.  It isn't the ecommerce
                                         guy's fault.
        \_ I graduated in 2001 and was wondering is there any way to make a
           career out of Java if you don't want to do web devel. Goddamn, I
           wish we actually were able to hone C/C++ skills at Cal. I guess
           this seems trollish, but if you graduated in the last 2 years or
           are still in school, you'll realize that this is not a troll at all.
           \_ agreed
           \_ agreed #2
           \_ I'm curious about this java craze.  I'm not in the job market
              so I don't know much about what skills are in demand.  For those
              of you that are looking, do you see more jobs that need Java/
              web stuff or those that need C/C++?  -alumni
              \_ "alumni" is plural, "alumnus" is singular.
              \_ In my experience, most Java work is monkey/grunt coder work.
                 Phil Greenspun has an amusing saying that Java is a good
                 language for roping together hundreds of mediocre programmers.
                 Regardless of what you think of Greenspun, I think it's a
                 pretty accurate description of Java.  Much of Java's
                 popularity is attributable to the fact that Sun's marketing
                 team went to town on the middle-managers of the world.  At
                 the end of the day, Java is an okay programming language
                 with a very wide library of utility classes.
                 \_Java is a AWESOME programming language, its the JVMs
                   that are mediocre, thus 90% of "Java's" problems are in
                   the implementation.
                   \_ Is there an underlying reason why the JVMs are
                      mediocre given that quite some time has elapsed
                      for people to get their act together?
                   \_ Okay troll.  I'll bite.  Why is Java AWESOME?  And if
                      Java is so AWESOME, why do all the non-Java engineers at
                      Sun love to bash on it so much?  Java does many things
                      right, but it also has many serious design flaws.  For
                      example, the stack machine implementation of the JVM
                      REQUIRED by the Java spec is idiotic (it kills
                      performance).  Another example is the fact that basic
                      types are not first order classes.  This is simply
                      idiotic.
           \_ Cal teaches CS.  Cal does not teach C/C++.  If you have a
              problem with this, go to a vocational school.  If you can't
              learn C/C++ on your own after learning language basics (and
              especially after learning Java), then, well, you deserve what
              you get.
              \_ This is a nice theory but try getting a C job when your school
                 didn't teach any C classes.  Live in the real world for once
                 instead of repeating the ancient CS dept. spew.
                 \_ I found it easy to get a job coding C. My major was mse
                    and I only took one CS class at cal (cs298 - fuzzy logic).
                    Most companies care about how well you can code, not
                    whether or not you took C programming classes.
                 \_ uh, I got a C job.  You should have been able to pick up
                    C while being an undergrad at Cal.  If you don't have a
                    job, what's keeping you from honing your C skills now?
                    Sheesh.  Do some legwork.
                    \_ So who the hell hired the two of you (above) to write
                       C if you hadn't done anything in C before?  Is the
                       stock public?  I want to know what to short.  Thanks.
        \_ Yes. Just find a company where they are into web-based development.
           All but three or four of the "engineers" in the linux/web startup I
           worked for were perl/php coders who didn't know c/c++, java or
           any other real language. Our company was bought by Sun for lots
           of money (~ $1 billion) and most of these '1337 P3RL H4X0R5 made
           enough on their ISO options to buy homes in Sunnyvale, San Jose
           and Cupertino. Some made enough to buy new M3s plus homes.
           \_ Well, you can keep your expensive homes and fancy cars, I'd
              rather use Java
              \_ ...and on an unrelated note, i'd rather live somewhere where
                  you don't have to be a millionaire to buy a decent (if
                  you call living in the south bay decent) home.
           \_ Uh, son, those days are dead.  They didn't get rich by coding
              toy web languages like php.  They got rich by being lucky.  The
              entire dotcom lottery was just that, a lottery.  Some people got
              really rich but most only did moderately well and the bottom
              quarter got totally fucked.
              \_  did they get fucked as bad as the bottom quarter in 1849?
                  this is not the first time greedy idiots invaded the Bay
                  Area.
                  \_ When my company started folding, we had to eat the
                     lesser skilled workers in order to survive.
                     \_ Why'd you wait that long?
                        \_ Needed to fatten em up a bit.
2002/7/13-15 [Computer/SW/Languages/C_Cplusplus] UID:25351 Activity:moderate
7/13    how do i pass variables to the system in C ?  e.g.
         system("echo input is %s", argv[1]);
        results in "input is %s" but I want the system to see argv[1]
        (I know i can just use printf, but not for what i really want to do).
        \_ sprintf into array, pass array to system?
        \_ so write your own function that takes a variable number of
           arguments, allocates memory, concatenates the arguments together,
           calls system on the combined string, and frees the memory.  That
           wasn't so hard, was it?  or, depending on what platform you're
           using, there may be some non-ANSI functions that do what you want.
        \_ Something like the following should work on Linux/BSD:
                #include <stdio.h>
                #include <stdlib.h>
                #include <stdarg.h>

                int  fsystem(const char *cmd, ...) {
                  va_list ap;
                  char buf[BUFSIZ];
                  int ret;

                  vsnprintf(buf,sizeof(buf),cmd,ap);
                  if (cmd == NULL)
                  return system(buf);
                    return -1;
                  va_start(ap,cmd);
                  ret = vsnprintf(buf,sizeof(buf),cmd,ap);
                  va_end(ap);
                  return (ret > sizeof(buf) ? -1 : system(buf));
                }
                \_ except for the obvious buffer overflow this code is
                   susceptible to. A very dangerous thing to do, especially
                   when passing things off to system().  One should include
                   sanity checking to keep someone from passing on args like
                   " ; /bin/rm -rf /"
                        \_ I see no buffer overflow as long as vsnprintf
                           is correctly implemented.  Of course system()
                           still sucks.
                  \_ It is an example. He would be a fool to use it
                     exactly as written without argument validation
                     and command checking. BTW what buffer overflow are
                     you talking about? I'm using a fixed size buffer,
                     and I'm passing sizeof(buf) to vsnprintf, which
                     is the safe way of doing this AFAIK. Is the problem
                     in the fact that the return code from vsnprintf
                     isn't checked? If so, I've just added that.
                     \_ I was hasty about the overflow, missing that it was
                        vsnprintf that was used, and thinking of vsprintf
                        instead, which would make it susceptible.  The
                        point about argument checking still stands.
2002/7/3-4 [Computer/SW/Languages/C_Cplusplus] UID:25273 Activity:moderate
7/3     What format string do I use with printf() if I want to print out a
        variable of type "long"?  Thanks.  -- yuen
                         \_ Type shrunken by the motd type shrinker.
        \_ man -S3 printf.
           \_ Thanks.  -- yuen
           \_ Thx.  -- yuen
              \_ Common word shrunken by the motd common word shrinker.
2002/5/7-8 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Misc, Computer/SW/Unix] UID:24733 Activity:insanely high
5/7     So how does /csua/bin/me record my identity?
        \_ It doesn't.  people are stupid.
           \_ All I was referring to was the fact that other users will see
              that you have a lock on the file, and then see new contents.
              Duh.
              \_ ...As opposed to editing the file in vi, finding that it's
                 locked, and running fstat anyway?  Whatever. -geordan
                 \_ fstat is a violation of my privacy rights.  I insist it
                    be deleted immediately.
                \_ Well, an alternative is to copy the motd, edit, then copy
                   back. You can diff to see if someone else changed it, and
                   manual merge. This way I never clobber anyone, of course
                   now I'm learning that other people feel free to clobber
                   me because I didn't lock the file before *they* started
                   editing. Well fuck you with a spoon.
                   \_ The whole point of this is that what _you're_ doing
                      is forcing EVERYONE ELSE to manually merge the motd
                      as well.  As most of us actually have lives, we are
                      asking those of you who are so scared of what you
                      say that you can't own up to it to either use the
                      lock or not complain. --scotsman
                      \_ Actually, I shouldn't make the assumption that
                         "most of us" have lives.  My apologies.  --scotsman
                      \_ no one is afraid.  they just don't care.  it isn't
                         important who said what.  and how the hell hard is it
                         to manually merge?  diff?  patch?  c'mon.  sometimes
                         I like what someone else has said on a topic better
                         than what I said and don't even bother putting mine
                         in.  it goes both ways.  its the motd.  relax.
                   \_ ok, fine, i'm wrong. except of course this way ppl
                      have to wait for slow typers and stuff like that.
        \_ read the script.  damn..
           \_ That probably requires enough clue to understand it. -geordan
                \_ It's not that hard.
                   \_ I realize; I looked at the script and saw nothing
                      that would hint at a lasting record of my identity
                      that ps -aux|grep motd.public wouldn't give.  That'
                      why I was wondering-- op
                        \_ emacs -nw ; C-xC-f /etc/motd.public ;
                           Now no one knows who you are unless they
                           happen to be running lsof for the few usecs
                           when you C-xC-s.
                           \_ U'R $O sUP34 733+ K@n 1 l3AR|V fR0M U 0 733T
                              mA$tUR?
                              \_ He wants to be anonymous, emacs is about
                                 as anonymous as you can get
                                 \_ then he's _rude_ and anonymous, and will
                                    have to deal with me overwriting his drivel
                                    because he refuses to use a lock.
                                    \_ so he'll deal.  its not like half or
                                       more of us aren't watching with scripts
                                       anyway.  emacs is hardly anonymous. I
                                       spent about 3 minutes writing a few tiny
                                       scripts that lets me figure out who is
                                       writing what about 90% of the time. you
                                       know what?  i find it doesn't matter.
                                       since i dont maintain a 'twink points'
                                       file and don't take the motd personally
                                       or seriously it just doesn't matter.
                                       you're all a bunch of two faced liars
                                       anyway posting to both sides of many
                                       threads.
                                       \_ That's a bald lie.
                                          \_ No it's not.
2002/4/26-27 [Computer/SW/Languages/C_Cplusplus] UID:24611 Activity:very high
4/26    Why when we travel close to speed of light, time starts to slow down and
        finally stops at v=c? Why time has anything to do with our cell division
        which controls our aging which also stops at v=c?
        \_ where's tom? ask ilyas about the stars....
        \_ why don't you talk to that guy who always hangs around leconte
           putting up posters about his "mono-pole" magnet?
           he'll answer all your questions.
        \_ time slows down for the other guys.
           \_ No, the rest of the world speeds up, you don't slow down.
        \_ go away.  Really.
        \_ obE190
        \_ For starter: when you "travel close to c", the speed of light with
           respect to you is still c.  At the same moment the speed of the same
           instance of light w.r.t. another person who is "stationary" is
           also c.  I vaguely remember that this strange observation is what
        \_ time dilation effects everything, including the atoms in your
           spawned Special Relativity.
        \_ time dilation affects everything, including the atoms in your
        \_ The above are all completely wrong.  As soon as you learn to format
           to less than 83 columns I'll reveal The Truth.
           cells.
           \_ but how cells in your body know time has stopped, this is weird.
              \_ You can't tell that time has "stopped", in your frame of
                 reference everything will appear normal. An observer in
                 in an inertial frame of reference (one that is at rest or
                 moving with constant velocity with respect to you) will
                        \_ what?  no.  if that other inertial frame of
                           reference is moving with constant velocity of 0
                           with respect to you, time will appear the same
                           in both reference frames.
                           \_ There is no way to objectively determine if
                              a frame is "at rest" or if both frames were
                              in motion at some time t with velocity v.
                              Consider the train experiment. The frame of
                              of the observer viewing the train and of
                              the train itself are both moving with
                              constant velocity equal to that of the
                              earth. Although the observer viewing the
                              train considers himself at rest, he really
                              isn't at rest.
                              \_ obviously, but my point was that observers in
                                 all reference frames do not think that time
                                 has stopped for you.
                 think that time has "stopped" for you. Both of you are
                 correct because of the nature of time and space.
             \_ hi, you're dumb.
        \_ Time has not stopped for the person travelling the speed of light.
           An observer with a different frame of reference will measure time
           has stopped for the individual travelling the speed of light.
        \_ Why are you people trying to explain -- oh, never mind. -geordan
        \_ hi, it's called physics 7c and get it over with.
2002/4/16 [Computer/SW/Languages/C_Cplusplus, Reference/Tax] UID:24449 Activity:high
4/15    Is homeowner insurance premium deductable in federal or CA tax form?
        Thanks.
        \_ No.
        \_ Aren't you a little late in asking this question?  In case this
           helps you, the answer is yes, but only if you file schedule C.
           You have to be self-employed AND have a home office.  All the
           house related expenses related to the home office is tax deductable
           including repairs, insurance, termite control, etc.  The key is
           schedule C.  Don't even try it without a schedule C.  You'll get
           audited.   -self-employeed sodan
           \_ Thanks for the answer.  I use TurboTax, so it's pretty easy to
              add one more entry and re-print the forms before midnight.  Too
              bad I'm not self-employed.
           \_ so if I file a schedule C (with income from a 1099-MISC)
              how much can I reasonably use in my itemized deduction? eg,
              if it was for some computer programming consulting, can I list
              any computer equipment I bought, and things like bandiwdth
              costs?    - !op
              \_ yes, computers, internet access, mileage traveling to the
                 job, etc are all deductable.  They key is keeping written
                 records and act like you run a business.  Separate bank
                 account for the business, keeping expense books, etc.
                 Self-employment is the key to making a lot of money AND
                 paying very little taxes.  Hell, I can buy a brand new
                 car and depreciate that as a "company car" if I wanted
                 to.  - self-employed soda.
                 \_ well, I guess for next year... but doesn't that mean
                    that you have to file *alot* of other forms? I was
                    reading some of the IRS pubs about various other
                    self-employed-type forms that you need and there
                    seems to be a ton.  - aspiring self-employed sodan.
2002/1/31-2/1 [Computer/SW/Languages/C_Cplusplus, Computer/SW] UID:23736 Activity:high
1/31    I want to control 16 different LED's by sending in
        short (~1ms, ~5V) pulses at various times and I need to be
        able to specify what the times are when the pulse begins
        (not necessarily the same for each LED). I'd like my
        computer to control all this, too. Whats the best
        way to do this?
        \_ If control doesn't need to be in real time, then a simple
           way to do it is to write to your parallel port, and build
           a simple board with ground from the port and have other
           pins drive the various LEDs.  Otherwise get a clock chip
           and some flipflops and build a logical circuit.  Look at
           your 150 book.
                \_ Thanks. how do I write to my parallel port
                   then?
                   \_ i realize that stfw is not a nice thing to say,
                      but i have done exactly this before, and there
                      is a document available on the web that has
                      many pages of detailed useful info on
                      the parallel port.  I ended up using the assembler
                      command "out" in C.  also, don't just drive the LEDs
                      straight from the parallel port, use a buffer of
                      some kind.
                      some kind. oh, yeah.  that's the hardware definition
                      of "buffer", not the software definition.  high impedance
                      input, low imdance output;otherwise you could fry your
                      parallel card!
2002/1/18-19 [Computer/SW/Languages/C_Cplusplus] UID:23592 Activity:kinda low
1/17    In ANSI C, is there a single function call to get the size of a file?
        I only know of fseek()+ftell().  Thx.
        \_ Aren't these two not ANSI C either? They're part of the standard
           C library, but not part of the language itself. And you probably
           want to look at stat/fstat (depending on whether you've opened the
           file already). -alexf
           \_ if you want to be pedantic, yeah, but I think it's safe to
              assume that the original poster meant, "Using the ANSI C standard
              library...".
        \_ while (getc()) i++;     /* (heh) */
           \_ wrong.  EOF != 0, so even after you added the required argument
              to getc, your loop would either terminate prematurely or loop
              forever.  perhaps you meant:
                while (getc(fp) != EOF) i++;
                \_ Oh yeah... it's been several years since I did any C.
                   I'm falling back on "it's the thought that counts!".
        \_ http://www.eskimo.com/~scs/C-faq/q19.12.html
2002/1/10 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Editors/Emacs] UID:23524 Activity:high
1/10    Can people learn not to save over what others have written on
        the motd?  Copy what you have written.  Reload the file, and
        paste it back.   Thank you.
        \_ Learn to pay attention to the lock file that is generated
           when someone else loads the motd into their editor and wait
           until they are done. Thank you.
        \_ Good Point. How do I reload the file in jove without quitting jove?
           \_ I believe it is C-x C-f, same as in emacs.
              \- there isnt a revert-buffer func? --psb
        \_ No.  No more so than they can learn to stop censoring other people's
           posts because they have a different opinion.
2001/11/28-29 [Computer/SW/Languages/C_Cplusplus, Computer/Theory] UID:23132 Activity:high
11/28   http://unicoi.kennesaw.edu/~jbamford/greguide/gresample.html
        Question 8, why isn't the answer C? 1/2 of a binary search (on
        average) would be (log2 N) - 1, where N is the number of nodes in
        a complete binary tree right? So C SHOULD be the answer. But for
        some reason it is not. Help.
        \_ you should send email to help@csua.berkeley.edu.  maybe they
        \_ you should send email to root@cory.eecs.berkeley.edu.  maybe they
           can help you there.
                \_ please don't waste our time                  -kevinm
2001/11/27-28 [Computer/SW/Languages/C_Cplusplus] UID:23120 Activity:high
11/27   http://www.CSUA.Berkeley.EDU/~ilyas/problems/hat_problem
        How many times are they allowed to pass and guess? God ilyas, you
        really need to clarify your questions.
        \_ once -!ilyas
        \_ Once.  There is an article in the NY Times about this problem.
           It's a genuine one, but see if you can get the correct answer.
           Hint:  It's not the trivial solution. -!ilyas
        \_ Yet another stupid problem. Two of the people pass, the other
           one will guess. That gives them a 50% chance of winning the price
           [sic]
           \_ Try again grasshopper.
        \_ How about this.  It's unlikely that all the hats will be the same
           color.  So if a player sees two hats of the a color, he guesses the
           other color, otherwise he passes.  This increases the chance of
           winning to 6 in 8.  (RRR, BBB are losers, other 6 combos are not.)
           \_ Congratulations.
              \_  Yes! I am the smartest man alive!
        \_ let each person decide for the other person, and then move to the
           left side of the room for blue hat, right side for red. So person
           A B C ( a decides for b, b decides for c, c decides for a). If person
           A is on the right side, b will say he (b) has a red hat.. etc
2024/12/25 [General] UID:1000 Activity:popular
12/25   
Results 151 - 300 of 415   < 1 2 3 >
Berkeley CSUA MOTD:Computer:SW:Languages:C_Cplusplus:
.