Search:

Type: Posts; User: Alogon

Search: Search took 0.01 seconds.

  1. Replies
    11
    Views
    330

    After looking at the assembler code, I seem to be...

    After looking at the assembler code, I seem to be mistaken about this.

    The first example, declaring an array, produces assembler code that does not contain the text as such anywhere. Instead,...
  2. Replies
    11
    Views
    330

    This is a small matter, but I am curious. In...

    This is a small matter, but I am curious.


    In a program, main() has this line twice:


    printf("key %u not found\n", key);


    A naive compiler might store the format text twice, although it...
  3. Replies
    4
    Views
    229

    Good idea! I'll do that. Thank you.

    Good idea! I'll do that. Thank you.
  4. Replies
    2
    Views
    248

    Output redirection

    Is there a way for a C program to determine whether its output to stdout is being redirected?

    (I would like to be able to display to stderr more warning messages if it is redirected than if not).
  5. Replies
    4
    Views
    229

    Perhaps it should accept a character pointer (to...

    Perhaps it should accept a character pointer (to an address in the input buffer or record) instead of an integer argument, since it isn't actually a proper integer with the wrong endianism.
  6. Replies
    4
    Views
    229

    #typedef question

    I've found a need to reverse the endianness of integer data read from some files I'm working with. So I wrote the following:




    typedef unsigned int uint;
    typedef unsigned char byte;
    uint...
  7. Replies
    3
    Views
    371

    >If you use the C99 version of the C standard VLA...

    >If you use the C99 version of the C standard VLA are legal, I don't recommend their use but they are legal.

    My education has now been updated. I too had assumed that they were not legal. Thank...
  8. Thread: Bufsiz

    by Alogon
    Replies
    3
    Views
    359

    Thanks! My program reads the files in binary...

    Thanks! My program reads the files in binary mode. It makes no difference whether they are binary files or not.

    From what I can grasp, if I don't call setbuf, then the system uses its own buffer...
  9. Thread: Bufsiz

    by Alogon
    Replies
    3
    Views
    359

    Bufsiz

    Running Windows, I'm using gcc as provided by Strawberry Perl.

    If I #define BUFSIZ 1024, I get a warning that in stdio.h it is already
    defined as 512.

    No problem, really. I can still...
  10. Replies
    4
    Views
    365

    Very interesting idea. But the article says "a...

    Very interesting idea. But the article says "a query returns either "possibly in set" or "definitely not in set." Are Bloom filters most appropriate for applications that seek only exact matches? As...
  11. Replies
    4
    Views
    365

    Searching texts via hashing

    This is more an algorithm question than a C language question at this stage. Can anyone refer me to article(s) that a non-mathematician can understand on the technique of using hashes to search a...
  12. Replies
    1
    Views
    215

    Floating point in printf()

    Maybe I'm missing something, but in the format field for printf() etc., I don't see a distinction between float variables and double variables. So how does the function know the size of the argument...
  13. Replies
    14
    Views
    581

    Over the last few hours, I've studied what a few...

    Over the last few hours, I've studied what a few sites have to say about error handling in C. They all begin by saying that error handling facilities are very limited, almost non-existent. There...
  14. Replies
    7
    Views
    480

    This peasant's algorithm is interesting. If one...

    This peasant's algorithm is interesting. If one must repeatedly multiply numbers by a single known multiplier such as 40, it's at least tempting to use addition and shifting rather than actual...
  15. Replies
    14
    Views
    581

    If a file has been properly opened and then...

    If a file has been properly opened and then corrupt data interferes with further I/O in the same file or another file, what would constitute graceful handling? The program needs to provide as...
  16. Replies
    14
    Views
    581

    And I was hoping to use exit() to simplify the...

    And I was hoping to use exit() to simplify the challenge of file I/O errors which should be rare but must always be anticipated. If we must preclude registering a function to free memory at exit,...
  17. exit() and return() in main(): what's the difference?

    I've written a simple void function that merely displays a string, and registered it with atexit().

    This function is called regardless of whether I end main() with exit() or return().

    Are these...
  18. Replies
    14
    Views
    581

    Thanks, I'm following your advice in this case. ...

    Thanks, I'm following your advice in this case.

    But here's another:

    1. Main() uses malloc() to allocate a block of memory.

    2. A function other than main() calls exit().

    3. Exit()...
  19. Shouldn't we write '\0' even if n==0, giving us...

    Shouldn't we write '\0' even if n==0, giving us an empty string corresponding to 0 bytes read?
  20. Replies
    6
    Views
    332

    Just out of curiosity, are there any modern...

    Just out of curiosity, are there any modern systems that implement it differently than by means of a stack?

    My first exposure to assembler programming was for the IBM 360, and it was nightmarish,...
  21. Replies
    5
    Views
    588

    Here's my solution. It took me an embarrassing...

    Here's my solution. It took me an embarrassing amount of time, not having used C for several years.


    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <ctype.h>
    int...
  22. Replies
    14
    Views
    581

    Agreed. But the program I'm working on reads a...

    Agreed. But the program I'm working on reads a random-access file at several points, and a few of these should be in separate functions. It seems more reasonable to make the FILE * a global variable...
  23. Replies
    14
    Views
    581

    Source file organization (best practice)

    Prior to main(), a C source file might contain:
    #pragma..
    #include...
    #define...
    typedef...
    global variables
    function prototypes (headers)
    functions?

    and probably half-a-dozen other things...
  24. Replies
    6
    Views
    332

    "Static" is a key word with which you can define...

    "Static" is a key word with which you can define variables in a function. It means that the variable is private to the function but retained between calls of the function. So, unlike ordinary local...
  25. Replies
    6
    Views
    332

    Usually, space is allocated for local variables...

    Usually, space is allocated for local variables in the stack. The address calling the function is at the top of the stack (conceptually, although it might well be the lowest memory address, as the...
Results 1 to 25 of 25