Search:

Type: Posts; User: christop

Page 1 of 20 1 2 3 4

Search: Search took 0.02 seconds.

  1. Replies
    4
    Views
    196

    My guess is you were just lucky. Most memory...

    My guess is you were just lucky. Most memory allocators will typically allocate a somewhat larger block than you request (to keep memory blocks aligned), so you were probably writing into that extra...
  2. Replies
    4
    Views
    196

    This line allocates enough space for only one...

    This line allocates enough space for only one char:



    Since you don't know how many tokens are in the string, you'll need to dynamically (re-)allocate result for each token (alternatively, when...
  3. Replies
    5
    Views
    304

    A statement like this: "cmd : %s\n",...

    A statement like this:



    "cmd : %s\n", cmd;


    happens to be valid C syntax, but it certainly doesn't do the same thing in C that it does in HolyC. You'll get more help if you stick to the...
  4. Replies
    4
    Views
    346

    The -w flag is only for printing the directory...

    The -w flag is only for printing the directory that a child call to make is entering/leaving, which is pretty much expected behavior.



    Really? What version of make are you using that doesn't...
  5. If for no other reason, it would be unwieldy to...

    If for no other reason, it would be unwieldy to have one header file for each symbol for anything but the most trivial programs. A common thing to do is to have one header file per "module" (which...
  6. Replies
    2
    Views
    222

    The argv arguments seem to be stored contiguously...

    The argv arguments seem to be stored contiguously (this isn't a guarantee, but it's how it's done in this implementation):




    arguments: ./test\0-something\0./a_directory\0./anotherdir
    argv...
  7. Replies
    1
    Views
    349

    Is this generated code? I don't know the reason...

    Is this generated code? I don't know the reason for this particular comma, but I often write code generators that put a comma after each array element like the following:



    int foo[] = {
    1,
    ...
  8. Replies
    2
    Views
    517

    I noticed you have a lot of lines like this: ...

    I noticed you have a lot of lines like this:



    if ((BCHchk && 64) != 0)


    What was the original assembly instruction for that statement? A bitwise "and" (&) would make a lot more sense to me...
  9. Quite high, though it'll take some time. ...

    Quite high, though it'll take some time.

    Quoting Wikipedia:


    And given that RSA-240 took 900 CPU core-years (a factor of 1/3), I estimate it'll take about 8100 CPU core-years to factor...
  10. Replies
    2
    Views
    394

    Both of the arguments are pointers to pointer to...

    Both of the arguments are pointers to pointer to uint8_t (i.e., double pointer). With 32-bit pointers, that would removes 4 bytes (and overwrite 96 bytes after the no_element array). You want pointer...
  11. Replies
    9
    Views
    896

    Just a note that getc() returns an int, so c...

    Just a note that getc() returns an int, so c should be declared as int c;:


    int buffer=0;
    int c;
    for (c = getc(veri); c != EOF; c = getc(veri))
    {

    if (c == '\n')
    ...
  12. Replies
    9
    Views
    947

    >Why will the newline be appended at the end of...

    >Why will the newline be appended at the end of the string? Isn't there any mechanism to ensure that the fgets() function doesn't do this, short of writing a method to remove it myself?

    Salem...
  13. Replies
    7
    Views
    1,626

    To be fair, you could have a factory that creates...

    To be fair, you could have a factory that creates objects from an instance. Suppose you want to create objects with the same complex set of arguments; you could have an instance that contains the...
  14. But note that adding the label, by itself,...

    But note that adding the label, by itself, doesn't actually do anything special. The code block would still be executed unconditionally. You'd need to change the previous if statements to a chain of...
  15. Replies
    4
    Views
    573

    Your scanf format is "%d %d" which tells scanf to...

    Your scanf format is "%d %d" which tells scanf to read an integer (in decimal), followed by whitespace, followed by another integer. Your input has a comma between the two integers, so scanf stops at...
  16. Replies
    1
    Views
    514

    I imagine it would be difficult if not impossible...

    I imagine it would be difficult if not impossible for the assert function/macro to do such a thing. You could do something like this, though:



    assert(a == b || (fprintf(stderr, "a is %d\nb is...
  17. Replies
    9
    Views
    1,099

    I'm on Linux Mint 19.3 with GCC 9.3.0, and I can...

    I'm on Linux Mint 19.3 with GCC 9.3.0, and I can confirm it happens for me too. I'm trying to find any undefined behavior in the code but can't so far. Definitely looks like a bug in GCC 9.
  18. Replies
    125
    Views
    10,342

    That sounds like a distro that I'd avoid if they...

    That sounds like a distro that I'd avoid if they have such egregious bugs in their C library. Do you recall which distro it was? There's a lot of software out there that assumes it can safely pass a...
  19. Replies
    125
    Views
    10,342

    In default_allocator, you can simplify the...

    In default_allocator, you can simplify the allocation line to this:



    tmp = realloc( ptr, get );


    because realloc will allocate new memory if the pointer is null.

    Also, you can remove if...
  20. Replies
    20
    Views
    1,333

    They are also already written and work quite...

    They are also already written and work quite well.

    Something something about reinventing the wheel.
  21. Replies
    17
    Views
    2,282

    The warnings about casting to void* in printf...

    The warnings about casting to void* in printf statements are not ignorable. Passing in the wrong pointer type (i.e., not a void pointer) has undefined behavior. Some architectures even have different...
  22. Thread: Unions...

    by christop
    Replies
    8
    Views
    1,594

    Indeed. Some systems might have only one...

    Indeed. Some systems might have only one floating-point type so that float is the same as double. Some systems might even have 16- or 32-bit char, which makes sizeof (float) equal 2 or 1. Using...
  23. Also, the array access in code like this: ...

    Also, the array access in code like this:



    (*(file_array + index)).Matricola


    is more usually written like this:
  24. Replies
    35
    Views
    4,238

    Do you already have a backup of all files? If...

    Do you already have a backup of all files? If not, what will you verify them against?

    Most backup software will do some sort of file verification automatically and will let you roll back to any...
  25. Replies
    35
    Views
    4,238

    For checksumming a large number of files, I'd use...

    For checksumming a large number of files, I'd use existing tools. You can do this easily in Linux, but it should work under WSL just as well:



    find DIR -type f -print0 | xargs -0 -n1 -P8...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4