Search:

Type: Posts; User: Golf7

Search: Search took 0.01 seconds.

  1. Replies
    19
    Views
    1,636

    In case you were confused by always getting 8...

    In case you were confused by always getting 8 from sizeof(backwards), remember that this will give you the size of a char pointer and not the size of the memory you allocated with malloc (which...
  2. Replies
    19
    Views
    1,636

    You haven't added a null character after the end...

    You haven't added a null character after the end of your word in backwards (even though you have allocated space for it) so strlen() doesn't know where it ends.
  3. Replies
    19
    Views
    1,636

    The standard requires sizeof(char) to be one.

    The standard requires sizeof(char) to be one.
  4. Replies
    19
    Views
    1,636

    sizeof(backwards) gives you the size of a char...

    sizeof(backwards) gives you the size of a char pointer, not the length of a string. Strings are terminated with a null character which is what strlen() will be looking for when it calculates the...
  5. amount * 2; The result of this will be amount...

    amount * 2;
    The result of this will be amount multiplied by 2 but it won't be assigned to anything. If you want the value of amount to be multiplied by two then you need to assign the result to...
  6. You have declared integer1, integer2 and sum...

    You have declared integer1, integer2 and sum inside main() and declared three variables with the same names inside addnumbers(). These are not the same.
  7. Replies
    4
    Views
    2,897

    You are using the number_of_stars variable for...

    You are using the number_of_stars variable for both the number of rows you want and the number of spaces to start each line with. In order to have the correct number of spaces at the start of each...
  8. Make that 11, I miscounted the number of...

    Make that 11, I miscounted the number of characters in your string which is actually 10 characters long itself. With the null character added to the end, the array length will be 11.
  9. char qs [ ] = "textishere"; This will...

    char qs [ ] = "textishere";

    This will initialize a single dimensional array, with the characters in your string plus a null character to end the string so the length will be 10.



    char...
  10. Replies
    1
    Views
    596

    The pointer called root inside insert() is local...

    The pointer called root inside insert() is local to the function not the same as the root pointer in main. It will initially point to the address you pass to it but changing it will not change what...
  11. Replies
    7
    Views
    1,428

    You need both s and t pointing to buffers where...

    You need both s and t pointing to buffers where your input is stored. One way of doing this is to use arrays as suggested above by vart which I see you have now done.
  12. Replies
    7
    Views
    1,428

    You haven't initialized s to point to a specific...

    You haven't initialized s to point to a specific locaion in memory where your input will be written to. Same also goes for t. You them to point to buffers where your input will be written to.
  13. Use the modulus operator (%) to calculate the...

    Use the modulus operator (%) to calculate the remainder. If a % b is zero then a is a multiple of b.
  14. Replies
    13
    Views
    6,782

    Not on Windows (even in 64 bit Windows a long is...

    Not on Windows (even in 64 bit Windows a long is still 35 bits).
  15. Replies
    13
    Views
    6,782

    I'm not sure which version of Windows you are...

    I'm not sure which version of Windows you are compiling for but even in 64 bit Windows a long is still 32 bits. You need to use long long.
  16. Replies
    7
    Views
    1,398

    See above though, I have noticed I much more...

    See above though, I have noticed I much more serious issue with the code in that I simply don't have enough bits (64 wouldn't be enough but I actually only have 40) available to parse 24 digits into...
  17. Replies
    7
    Views
    1,398

    Yes, I could do that but I wasn't sure how costly...

    Yes, I could do that but I wasn't sure how costly this would be. As for using an unsigned long long, I didn't think I would have been running into the sign bit due to only shifting by 24 bits but...
  18. Replies
    7
    Views
    1,398

    The smallest possible fraction is 2^(-24) which...

    The smallest possible fraction is 2^(-24) which in decimal is 0.000000059604644775390625. If I attemped to parse this from a string then since there are 24 digits after the decimal point, the...
  19. Replies
    7
    Views
    1,398

    Fixed point from string

    Hi, I have been writing a fixed point library the would handle fixed point numbers with an 8:24 whole/fraction ratio. This has been working quite well but since I have a 24 bit fractional part, it...
  20. Thread: HDC and HFONT

    by Golf7
    Replies
    4
    Views
    1,654

    Now I understand what an HDC is, I can see that...

    Now I understand what an HDC is, I can see that it will cause a leak in the above code as hdc is local to the function and so not accessible once the function returns. The font in question though is...
  21. Thread: HDC and HFONT

    by Golf7
    Replies
    4
    Views
    1,654

    HDC and HFONT

    I'm curios as to why this



    void initialize_font(HFONT hf, HWND hwnd) {
    HDC hdc;
    TEXTMETRIC tm;
    hdc = GetDC(hwnd);
    hf = CreateFont(20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Times New...
  22. Thread: File input

    by Golf7
    Replies
    5
    Views
    1,118

    Here is the revevant part of the code: int...

    Here is the revevant part of the code:
    int main(void) {
    FILE *filein;
    filein = fopen("input.txt", "r");
    struct Node* head = NULL;
    char* input;
    while(!feof(filein)) {
    input =...
  23. Thread: File input

    by Golf7
    Replies
    5
    Views
    1,118

    File input

    I have been using fgets() to read lines of a file I have and store them in a linked list. This has been working very well but after the last line I seem to end up with "x(smiley face)>" in the list....
  24. Replies
    1
    Views
    1,355

    Deleting from linked list

    I've been working my way through SAMS teach yourself C for Linux programming over the last year and have recently been studying linked lists.

    To delete from the middle of a linked list the book...
Results 1 to 24 of 25