Search:

Type: Posts; User: Dave Evans

Page 1 of 20 1 2 3 4

Search: Search took 0.02 seconds.

  1. Replies
    3
    Views
    988

    for (i = 0; i < number_of_questions; i++) { ...

    for (i = 0; i < number_of_questions; i++) {

    /* use getline() to read question[i].q from the file */

    for (j = 0; j < number_of_answers_for_each_question; j++) {

    /* use...
  2. Thread: math.h

    by Dave Evans
    Replies
    3
    Views
    8,359

    While you are at it, I would suggest that you...

    While you are at it, I would suggest that you turn on compiler warnings:



    gcc -Wall -W -pedantic yourprogam.c -o yourprogram -lm


    You might see some helpful stuff like
  3. Replies
    8
    Views
    1,786

    You want to interpolate each rgb value. The...

    You want to interpolate each rgb value.

    The formula for linear interpolation is f(x) = f(a) + (b-a)/(x-a) * (f(b)-f(a))

    If a = 0.0, b = -1.0, f(a) = 0, f(b) = 255 it could go something like
    ...
  4. Replies
    8
    Views
    5,702

    In fact, with 32-bit ints (which would be my...

    In fact, with 32-bit ints (which would be my guess, given the symptoms), code like the posted program gives the following values



    11 -> 39916800 (OK)
    12 -> 479001600 (OK)
    13 -> ...
  5. Replies
    2
    Views
    15,030

    You have an array of structs. There are two...

    You have an array of structs. There are two structs in the array.

    If you want to use a pointer to access the structs, then you could do something like



    MeasObjList_t * pMeasObjList =...
  6. Since INT_MIN is the most negative value, I think...

    Since INT_MIN is the most negative value, I think you probably mean
    INT_MIN == -(INT_MAX -1)

    I'll answer a question with a couple of questions:

    Is there any advantage of such a system over the...
  7. In fact, as laserlight said, for two's complement...

    In fact, as laserlight said, for two's complement number systems both forms give "bad" results for exactly one particular value of integer.

    Implementing either form will necessarily cause "integer...
  8. Replies
    8
    Views
    3,835

    The "garbage" is undoubtedly the output of gzip...

    The "garbage" is undoubtedly the output of gzip -c. (With the -c flag, gzip sends output to stdout.)

    D
  9. Replies
    5
    Views
    3,610

    Isn't it better to get to the bottom of things? ...

    Isn't it better to get to the bottom of things?

    1. The following leads to a very poor approximation for your value of x. Shouldn't it be something like if (fabs(x) < 0.1) or (fabs(x) < 0.2)?

    ...
  10. Replies
    10
    Views
    31,895

    I'll get you started. A possible Game Plan: ...

    I'll get you started.

    A possible Game Plan:

    1. Write the specification for htonl()
    2. Implement it
    3. Write the specification for ntohl()
    4. If (3) is identical to (1), then what? If (3) is...
  11. Replies
    10
    Views
    31,895

    Here's a thought: Why would you (or anyone else,...

    Here's a thought: Why would you (or anyone else, for that matter) use htonl() on receive?

    Even though I said that the two implementations have the same results (a statement based on my personal...
  12. Replies
    10
    Views
    31,895

    In fact there is no difference; the...

    In fact there is no difference; the implementations perform the same task.

    For both htonl() and ntohl() operating on 32-bit integer data types:

    Little-endian architecture ==> swap bytes...
  13. Replies
    7
    Views
    1,238

    Some compilers require that all data declarations...

    Some compilers require that all data declarations in a block must appear before executable statements.


    All compilers require semicolons at the end of statements.

    (Why not keep the printf...
  14. Replies
    18
    Views
    2,420

    Of course: you are correct; I misunderstood. D.

    Of course: you are correct; I misunderstood.

    D.
  15. Replies
    18
    Views
    2,420

    It isn't my example; I was just correcting what I...

    It isn't my example; I was just correcting what I thought was a (typographical) syntax error from the previous post.

    I was mistaken about the intent of the previous post. I regret my error.

    In...
  16. Replies
    18
    Views
    2,420

    TO make the parameter a pointer to an...

    TO make the parameter a pointer to an array[10][20] of ints, it should be:


    void func(int (*arr2d)[10][20]);


    Of course, functions defined like this will only work for that particular size...
  17. Replies
    29
    Views
    6,307

    By "works", I assume you mean that the compiler...

    By "works", I assume you mean that the compiler no longer chokes. In my experience, that may or may not mean that the functionality is preserved. I stand by my comment about the importance of a test...
  18. Replies
    29
    Views
    6,307

    Been there; done that! (And the Boss told me not...

    Been there; done that! (And the Boss told me not to change anything; just recompile.)

    What happens if you do it as follows?


    #include <stdio.h>
    #define __FILE FILE


    More importantly: Do...
  19. Replies
    12
    Views
    1,988

    As a legacy from the days of DOS and 8-inch...

    As a legacy from the days of DOS and 8-inch floppy disks, I/O library routines in Borland and Microsoft Windows compilers (maybe others too, but not GNU/cygwin) usually consider the character ctrl-z...
  20. Replies
    2
    Views
    5,648

    First of all you seem to be trying to do the...

    First of all you seem to be trying to do the calculations using a formula that assumes that the Gregorian calendar has been in effect since the year zero. Beside the fact that your assignment of...
  21. Replies
    9
    Views
    4,031

    It has been pointed out that these two items will...

    It has been pointed out that these two items will have same value, however they are not the same.


    For an array of "anything":

    The name of the array used by itself (no [] brackets) is taken to...
  22. The second edition. argv is the name of an...

    The second edition.


    argv is the name of an array of pointers.

    argv[0] is a pointer to the program name.

    The first argument is pointed to by argv[1] (if there were any arguments).

    First...
  23. Replies
    9
    Views
    2,879

    Is there any difference? D

    Is there any difference?

    D
  24. Replies
    2
    Views
    5,413

    In foo.c, you could even use extern int...

    In foo.c, you could even use


    extern int p_int[];


    A pointer is not the same as an array although you can use array notation for dereferencing a pointer. (In other words, deferenced pointer...
  25. Replies
    12
    Views
    12,763

    For this file nColors = 0 The original program...

    For this file nColors = 0

    The original program is only writing one byte where it should be writing 1024. That's why the original program gave an output file that was 1023 bytes shorter than the...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4