Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  • Users: WebDrake
  • Order by date
  1. WebDrake

    Object-oriented programming: Objective-C or C++?

    I really loved Kochan's C book; it's a fantastic resource and getting it made some major improvements to my skills and understanding. I wish he'd written one for C++, since in the short term that's the language I've decided to go with, but I'll keep ObjC in mind for the future.
  2. WebDrake

    Object-oriented programming: Objective-C or C++?

    Not really true. A statement like a = malloc(10*sizeof(*a)); is good code and makes sense in C, but won't work in C++. The code that will work in C++, such as, a = (int *)malloc(10*sizeof(int)); is problematic from a C point of view, because the cast prevents the C compiler from...
  3. WebDrake

    Tracing a rounding error

    Belated thanks for the useful replies. And yes, I know it's normal floating point behaviour. I'm just interested in tracing when numerical methods diverge. :-)
  4. WebDrake

    Tracing a rounding error

    Sure. I know the principle, I was just wondering if there was any advice on how to trace exactly where such an error comes in. My impression was that the error was occurring in the event of something like this happening: x += a; x -= a; Where a is of much greater order than x (e.g. a...
  5. WebDrake

    Tracing a rounding error

    I'm wondering if anyone can give any advice on tracing a rounding error in a program. I have two slightly different implementations of a process, which basically come down to the following. In Version 1, various increments are added to a double variable, and at the end I check to see if it is...
  6. WebDrake

    Some issues with mixing C and C++

    Well, C++ doesn't like malloc() statements much, unless they're cast. :-( With C I compile with the flags -ansi -pedantic -Wall, so, the strictest C89 compatibility (I believe?). Regarding your suggestion for the extern "C" { problem, I think I'll still have the same annoying unwanted...
  7. WebDrake

    Code efficiency question

    Hi Dian, Thanks for the thoughts. For what it's worth, I am talking about having very large numbers, so little savings are often important. In the case of this particular loop, N will not be large; but the whole thing will be contained in a bigger loop that will go round on the order of 100...
  8. WebDrake

    Code efficiency question

    I'm aware of that. For the case I'm concerned with, check remains at a single value throughout either option.
  9. WebDrake

    Code efficiency question

    Does anyone have any comments on which of these pieces of code will run more efficiently? In these code examples, check is a variable of type bool (it is an actual variable, not an expression that is reevaluated each time the if() statement is run), and i and N are unsigned ints. if(check) {...
  10. WebDrake

    Some issues with mixing C and C++

    I've started introducing some C++ modules to my code project (scientific number-crunching), where it's convenient to do so, and have been following the instructions at http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html for mixing code. A few things are niggling me, mostly trivial, but...
  11. WebDrake

    Object-oriented programming: Objective-C or C++?

    Good point. Does ObjC have an ANSI standard? I recall that C++ does. As for portability, I'm unlikely to be using my code on any systems where gcc will not run.
  12. WebDrake

    Object-oriented programming: Objective-C or C++?

    AAARRRGHHHHH! You know I wouldn't actually use it like that, right? :-)
  13. WebDrake

    Pointers to constants?

    Am I just being thick here or... ... well, if I understand you right, the second argument is a pointer to the value you wish to write, or read to. So if x is the variable whose value you wish to pass, you would write, status = EEPROM_IO(0,&x,(unsigned int)EEPROM_SIZE,CLEAR); ... right? So...
  14. WebDrake

    Array lengths

    I've already fallen for that one, or rather, thought it up, found it didn't work and quickly realised why (it doesn't work for the same reason that sizeof(*a) does work, right?). Almost invariably when I'm dealing with arrays, they are malloc'd pointers, so this isn't a solution. I guess...
  15. WebDrake

    Object-oriented programming: Objective-C or C++?

    I noticed... ::sigh:: Thanks very much for helpful advice! :-)
  16. WebDrake

    Array lengths

    Is there a maximum array length in C, other than the size of the computer's memory? ... and ... are there any functions in the standard library which might tell you the length of an array (other than strlen(), which I know about)?
  17. WebDrake

    Object-oriented programming: Objective-C or C++?

    Great. In that case I'm tempted to go with ObjC since it's a strict superset of C, meaning C code can be cut-and-paste without any worries. I'm thinking of code like this: { int *a, *b, *c; a = malloc(5*sizeof(*a)); b = malloc(5*sizeof(*b)); c = malloc(5*sizeof(*c)); } ...
  18. WebDrake

    Object-oriented programming: Objective-C or C++?

    Thanks for the suggestions. :-) I have to say that employment isn't really an issue here since I don't make a living from programming. The main thing for me is what might be preferable from a number-crunching speed point of view.
  19. WebDrake

    Object-oriented programming: Objective-C or C++?

    Hello all, For my code work up until now (scientific number-crunching) I have used C, but there are a handful of cases where it would be useful to have some object-oriented programming (e.g. for simulation of traders bidding on a stock market, or similar multi-agent work). I've dealt with this...
  20. WebDrake

    Bizarre segmentation fault involving i/o of data

    Whoops. Should reverse the order of checking in the while() section: while((check==NULL) && (fgets(query,BUFSIZ,stdin) != NULL))

Part and Inventory Search

Back
Top