Search:

Type: Posts; User: Malcolm McLean

Page 1 of 16 1 2 3 4

Search: Search took 0.01 seconds.

  1. To explain what is going onn here abit more, you...

    To explain what is going onn here abit more, you are guaranteed
    that the first member will have the same address as the structure itself. You also guarantted that when you declare an array of...
  2. You've failed to understand how to use pointers...

    You've failed to understand how to use pointers to return values.
    You need to declare the variable, then take its address, and pass that to the function expecting a pointer. If you pass a null...
  3. Replies
    1
    Views
    121

    Go to my website and download bmp.c from the...

    Go to my website and download bmp.c from the BabyX resource compiler. This contains a function for saving an array as a .bmp
    file.

    Now your problem is to create the plot as a raster.

    In C,...
  4. It's quite common in C to need a fairly large...

    It's quite common in C to need a fairly large number of boolean
    parameters. Instead of passing large numbers of parameters
    individually, it is no uncommon to wrap them up into a single
    integer,...
  5. Replies
    2
    Views
    186

    Multi-dimensional arrays are an advanced feature...

    Multi-dimensional arrays are an advanced feature of C, and they don't work wth the rest of the language as you think they should. Unfortunately most C primers introduce multi-dimensional arrays...
  6. That's no good. It's also surprising. The whole...

    That's no good. It's also surprising. The whole point of input is that the program reads it, and modifies its behaviour accordingly.
  7. One problem with beginner exercises is that...

    One problem with beginner exercises is that handling text input correctly is quite difficult, because in theory the input file can be anything.

    However it seems that you are guaranteed digit...
  8. Replies
    6
    Views
    258

    Go to my website and look at the Baby X resource...

    Go to my website and look at the Baby X resource compiler. It contains a file called bmp.c which provides functions for loading and saving .bmp files.
  9. Replies
    2
    Views
    255

    You need to post a bit more. This looks...

    You need to post a bit more. This looks suspicious as strcncmp takes two pointers. If p is a char ** it is correct, but then what is p pointing to? It's probably set up incorectly and p needs to be...
  10. He's reading the characters as bytes, so not...

    He's reading the characters as bytes, so not supporting them.
    If you've a big alphabet, there's no simple efficient way of counting each character in standard C. If you use C++, there are several...
  11. You want to create a histogram of all characters...

    You want to create a histogram of all characters in a file. Characters are 8 bit, so the easiest way to do this is to declare a 256-member array of ints and initialise them all to zero. Then go...
  12. Strings are terminated with nulls in C. So to...

    Strings are terminated with nulls in C. So to step through a string character by character, you don't stop at a set length. The most efficient way to do it is




    int stringfunction(char *text)...
  13. Yes, bubble sort can be adapted to work on linked...

    Yes, bubble sort can be adapted to work on linked lists. Bubble sort means pass through the list, and if two items are in reverse order, swap them and set a flag. Stop when you have passed through...
  14. Replies
    3
    Views
    240

    The fields of the struct pixel are ints. Probably...

    The fields of the struct pixel are ints. Probably 4 bytes. The values in the .bmp file are 8 bit. You are reading 1 byte into a 4 byte variable, and getting nonsense results.
  15. Replies
    4
    Views
    331

    Windows encourages this approach in its own...

    Windows encourages this approach in its own functions for manipulating .bmp files. However really it is bad way of doing it. C can run on big or litle-endian machines, and the sizes of basic types...
  16. Replies
    4
    Views
    256

    This sounds like an interesting project. There...

    This sounds like an interesting project.

    There are many document formats. They all need specialised libraries to parse and extract the text data. I'd advise you to ignore them or you'll spend all...
  17. If using UTF-8, just create the degree symbol...

    If using UTF-8, just create the degree symbol manually.



    const char degreesymbol[3] = {194, 176, 0};

    firstdegree = strstr(searchstring, degreesymbol);
  18. Replies
    4
    Views
    254

    C++ provides direct support for programing...

    C++ provides direct support for programing concepts that C doesn't. C restricts you to subroutine calls, loops, if statements, indirection (pointers), arrays, and aggregate structures. That's about...
  19. Replies
    6
    Views
    303

    To be fair, you'd have to go through the C...

    To be fair, you'd have to go through the C standard chapter and verse to see whether it is defined or not. It's clearly buggy code.
  20. Replies
    6
    Views
    303

    s is the first member of struct "Object". So the...

    s is the first member of struct "Object". So the address of the member is constrained to be the same as the address of the structure. You are treating NULL as the base address of the Object pointed...
  21. The way to approach this is to iterate though the...

    The way to approach this is to iterate though the whole string, one character at a time. Then you maintain a state variable, "on word" or "off word", depending on whether you are in a word or not....
  22. Replies
    4
    Views
    259

    3) they use expr as a parameter without any...

    3) they use expr as a parameter without any declaration of it, then when they call this function such as:
    vlr = csmap->vlr;
    ogs_assert(val);
    the question is: can we consider a expr as a type of...
  23. Replies
    2
    Views
    226

    If you typedef your structs, the typedef has to...

    If you typedef your structs, the typedef has to come before any
    prototypes which reference that typedef. However in this case,
    the prototype newIncident() doesn't reference any structs,
    so it can...
  24. Replies
    8
    Views
    259

    That's an extension. Some compiler will accept...

    That's an extension. Some compiler will accept dollar signs in identifiers, but some won't.
    It's quite useful actually as it creates a namespace which cannot clash with conforming, portable code.
  25. Replies
    8
    Views
    259

    The dollar sign doesn't appear as a token or part...

    The dollar sign doesn't appear as a token or part of a token in C. Probably because it might not be available in a non-American context. You do see it sometimes as an extension, but I'd agree that $>...
Results 1 to 25 of 393
Page 1 of 16 1 2 3 4