Search:

Type: Posts; User: Barney McGrew

Page 1 of 18 1 2 3 4

Search: Search took 0.02 seconds.

  1. Replies
    1
    Views
    1,076

    Looking for a clown.

    I am looking for a clown to replace me as a regular on these forums. You won't receive payment but you can consider it a service to the cprogramming.com community! Anyone who's interested in this...
  2. Replies
    6
    Views
    1,051

    One other common use is to get the number of...

    One other common use is to get the number of elements in an array. This can be used like so:

    int x[10];
    size_t i;

    for (i = 0; i < sizeof x / sizeof x[0]; i++)
    x[i] = 1;
  3. Replies
    10
    Views
    854

    What you have is fine as it is; it's an error to...

    What you have is fine as it is; it's an error to dereference currentP->next if currentP->next stores a null pointer. Your code will ensure that currentP->next isn't dereferenced in such a case.
    ...
  4. Replies
    33
    Views
    9,914

    qsort requires each element to be of the same...

    qsort requires each element to be of the same length so, obviously, you can't move strings around in an array using it, since they may have different sizes. What you need to do is store a pointer to...
  5. Replies
    33
    Views
    9,914

    Try another source: qsort(3) - Linux manual page...

    Try another source: qsort(3) - Linux manual page
  6. Replies
    16
    Views
    1,655

    Yeah. Make your program data-oriented, so that...

    Yeah. Make your program data-oriented, so that all the information you spam the user with is stored in one place, then write your program so that it operates on that data.
  7. Replies
    33
    Views
    9,914

    Why not use a growing array to store the input?...

    Why not use a growing array to store the input? Your program would be more portable since you won't need to use stat.

    In regard to your compare function, try reading the example provided in 'man...
  8. Replies
    30
    Views
    2,493

    ',' is evaluated after '='.

    ',' is evaluated after '='.
  9. Why don't you just do this?: #include...

    Why don't you just do this?:

    #include <stdio.h>

    int printmac(const unsigned char ptr[6])
    {
    return printf("%02x:%02x:%02x:%02x:%02x:%02x\n",
    ptr[0], ptr[1], ptr[2], ptr[3], ptr[4],...
  10. Some men annoy a lad called waitpid with their...

    Some men annoy a lad called waitpid with their concerns.
  11. Replies
    6
    Views
    1,321

    Violence never solves anything. Try again when...

    Violence never solves anything. Try again when you're ready to use your keyboard properly.
  12. Replies
    7
    Views
    987

    How about completely rewriting it? static int...

    How about completely rewriting it?

    static int pali_(const char *start, const char *end)
    {
    return start >= end ? 1 : *start == *end && pali_(start + 1, end - 1);
    }

    int pali(const char *s)
    {...
  13. Replies
    15
    Views
    4,815

    You can't do this in standard C, so find an...

    You can't do this in standard C, so find an external library that will do what you want and, if you have trouble with that library, you'll surely get better help by asking the people who maintain...
  14. Replies
    10
    Views
    5,133

    C's written in English, though compilers and...

    C's written in English, though compilers and interpreters for it are written in a variety of languages. You even see C implementations that use multiple programming languages, for instance, a...
  15. Replies
    18
    Views
    2,395

    You don't want to use calloc for pointer types,...

    You don't want to use calloc for pointer types, since it initialises them with all bits zero, which is a meaningless value for pointers. malloc would be a better choice and, if you need them...
  16. char *strcat(char *s, const char *append) { ...

    char *strcat(char *s, const char *append)
    {
    return strcpy(s + strlen(s), append), s;
    }
    Figure out how to implement strcpy and strlen, and it should be simple enough to understand.
  17. @megafiddle: Well, I started writing a response,...

    @megafiddle:
    Well, I started writing a response, but most of what I was writing seemed to be the same points made in 'C For Smarties', so I'll just post a link to that.
    C For Smarties
  18. Replies
    17
    Views
    2,151

    It's implementation-dependent. Your system should...

    It's implementation-dependent. Your system should provide a way to redirect your program's output to a printer.

    EDIT: On most Unix-like systems that's as easy as:
    ./program > /dev/lp

    You could...
  19. I see. This makes me wonder about code like: ...

    I see. This makes me wonder about code like:

    int a[3][10];
    a[0] < a[2];
    Would you say it has undefined behaviour? On the one hand, both pointers point into separate aggregates, but on the other,...
  20. 'void *' and 'char *' are both able to represent...

    'void *' and 'char *' are both able to represent all object pointer types. (6.2.5p28, 6.3.2.3p1)

    Could it be that when two pointers are cast to 'void *', that the destination pointers are...
  21. Replies
    8
    Views
    1,970

    '\n'

    '\n'
  22. Replies
    8
    Views
    1,970

    You'll need to include to make the...

    You'll need to include <stdlib.h> to make the declaration for qsort available as well. It's also a good idea to terminate your program's output with a new-line character.
  23. Replies
    6
    Views
    15,540

    Looks like somebody needs a diaper change!

    Looks like somebody needs a diaper change!
  24. In your first post you mentioned that the size...

    In your first post you mentioned that the size would be eight bits for the header field. Assuming you're referring to the packed size and that CHAR_BIT is 8, I think you want the following:
    unsigned...
  25. Are you sure it has undefined behaviour, rather...

    Are you sure it has undefined behaviour, rather than unspecified behaviour? If it were true I think that would make it impossible to implement memmove() in a standard-compliant manner.
Results 1 to 25 of 426
Page 1 of 18 1 2 3 4