Search:

Type: Posts; User: Alogon

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Replies
    4
    Views
    8,964

    Question about atoi()

    I've been using atoi() to read a field in a text file and store the binary number in an unsigned int field of a struct. From what I can tell, the results are not what I want if the number is within...
  2. Replies
    11
    Views
    3,233

    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,...
  3. Replies
    11
    Views
    3,233

    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...
  4. Replies
    4
    Views
    4,308

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

    Good idea! I'll do that. Thank you.
  5. Replies
    2
    Views
    4,809

    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).
  6. Replies
    4
    Views
    4,308

    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.
  7. Replies
    4
    Views
    4,308

    #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...
  8. Replies
    3
    Views
    4,018

    >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...
  9. Thread: Bufsiz

    by Alogon
    Replies
    3
    Views
    14,751

    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...
  10. Thread: Bufsiz

    by Alogon
    Replies
    3
    Views
    14,751

    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...
  11. Replies
    4
    Views
    3,593

    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...
  12. Replies
    4
    Views
    3,593

    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...
  13. Replies
    1
    Views
    5,609

    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...
  14. Replies
    14
    Views
    11,566

    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...
  15. Replies
    7
    Views
    5,686

    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...
  16. Replies
    14
    Views
    11,566

    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...
  17. Replies
    14
    Views
    11,566

    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,...
  18. 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...
  19. Replies
    14
    Views
    11,566

    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()...
  20. 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?
  21. Replies
    6
    Views
    4,495

    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,...
  22. Replies
    5
    Views
    6,228

    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...
  23. Replies
    14
    Views
    11,566

    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...
  24. Replies
    14
    Views
    11,566

    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...
  25. Replies
    6
    Views
    4,495

    "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...
Results 1 to 25 of 26
Page 1 of 2 1 2