Search:

Type: Posts; User: john.c

Page 1 of 20 1 2 3 4

Search: Search took 0.02 seconds.

  1. Replies
    6
    Views
    129

    What program? Give a link. What did you...

    What program? Give a link.


    What did you google? Give a link to the results that led you to your conclusion.

    I don't think mingw should be needed if you are using wsl and ubuntu.
  2. A simple example: #include ...

    A simple example:


    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>

    char *mult(const char *a, const char *b) {
    int alen = strlen(a), blen = strlen(b);
    char *c =...
  3. The 509 limit is C89's limit for string literals,...

    The 509 limit is C89's limit for string literals, not arrays. It's raised to 4095 in C99. Implementations are likely to set it much higher or make it unlimited.

    A char array would presumably have...
  4. Try replacing lines 58 and 59 with this: ...

    Try replacing lines 58 and 59 with this:


    if (text.format != 8)
    printf("bad format\n");
    else {
    char *v = text.value;
    while (*v) {
    if (strcmp(v,...
  5. Replies
    3
    Views
    220

    The final condition definitely doesn't make sense.

    The final condition definitely doesn't make sense.
  6. For a quick fix to returning a local you could...

    For a quick fix to returning a local you could make mul static.
    Better still, return a malloc'ed string.
    MAX should be a define.

    In your for (i = lb; i >= 0; i--) loop, k is going way out of...
  7. Replies
    7
    Views
    371

    Take a look at the source code for killall5...

    Take a look at the source code for killall5 (which pidof actually runs; note line 1021 which passes control to the function main_pidof).
    sysvinit/killall5.c at master * limingth/sysvinit * GitHub
    ...
  8. Replies
    1
    Views
    410

    "data" will never be NULL, so you can't use it to...

    "data" will never be NULL, so you can't use it to detect a sublist. You need a separate type member.
  9. Here's an example of a working program without...

    Here's an example of a working program without any optimizations except for only checking divisors up to the square root. Note that it's easy to only check odd numbers by dealing with 2 separately.
    ...
  10. Replies
    9
    Views
    480

    No problem. Note that you didn't use the fgets...

    No problem. Note that you didn't use the fgets followed by *scanf idiom correctly. The *scanf shouldn't have been an fscanf but an sscanf, taking input from the line you read with fgets. One good...
  11. Replies
    9
    Views
    480

    Since you've already read through the whole file...

    Since you've already read through the whole file to determine the number of lines, you need to reset it back to the beginning to read the numbers. You can close it and re-open it, use fseek, or use...
  12. Replies
    7
    Views
    458

    Yes, the reasonable implementation-defined...

    Yes, the reasonable implementation-defined options for a right-shift would be whether it is "arithmetic" or "logical". I'm aware that it works in either case in your situation, but I don't understand...
  13. Replies
    7
    Views
    458

    Since pointers are obviously unsigned integers it...

    Since pointers are obviously unsigned integers it seems logical to store it in an unsigned integer.

    At any rate, right-shifting a signed integer with a negative value (high bit set) is...
  14. Replies
    7
    Views
    458

    Sounds good. Make sure it's an unsigned long,...

    Sounds good. Make sure it's an unsigned long, though. I should have used an unsigned long long in the code I posted. Note that, technically, long is not guaranteed to be 64 bits, although it almost...
  15. Replies
    7
    Views
    458

    #include #include #include...

    #include <stdio.h>
    #include <stdint.h>
    #include <inttypes.h> // this includes stdint.h, too

    int main()
    {
    void *p = &p; // holds address of itself

    // The usual way.
    ...
  16. Replies
    6
    Views
    436

    I forgot to reset the variable arguments for the...

    I forgot to reset the variable arguments for the vfprintf call. It should be:


    void print(const char *fmt, ...) {
    va_list va;
    va_start(va, fmt);

    vprintf(fmt, va);
    ...
  17. Replies
    6
    Views
    436

    _exit() doesn't flush open file buffers. exit()...

    _exit() doesn't flush open file buffers. exit() does.
    You may wish to flush after every line.
    Instead of writing all output twice you could use a function like this:


    void print(const char...
  18. In the 4238-line file, make sure that there is...

    In the 4238-line file, make sure that there is not an extra space before or after the word senator.
  19. I notice that you forgot to initialize k to 0...

    I notice that you forgot to initialize k to 0 before filling your jobs array (which would be better named "jobs" instead of the meaningless "arr"). You are also not testing for end-of-file correctly....
  20. I don't use Windows but maybe you need to...

    I don't use Windows but maybe you need to GlobalFree(hData) before the function returns. And you don't need the double pointer.
    Untested:


    #include <windows.h>
    #include <stdio.h>
    #include...
  21. Replies
    4
    Views
    465

    Think again.

    Think again.
  22. Replies
    1
    Views
    361

    You aren't calling the function, just...

    You aren't calling the function, just "mentioning" the function name, which does nothing.


    #include <stdio.h>

    void foo()
    {
    printf("X\n");
    }
  23. Replies
    4
    Views
    465

    I don't know the problem, but I think it's better...

    I don't know the problem, but I think it's better written like this:


    #include <avr/io.h>
    #include <util/delay.h>

    int main()
    {
    while (1)
    {
  24. Replies
    1
    Views
    285

    wordCountChoice should be an integer, not a char*...

    wordCountChoice should be an integer, not a char* if that's what it is.
    You can convert the string input to an integer with atoi().
    Also note that line 2 above does nothing.
  25. Replies
    9
    Views
    764

    I looked at the generated assembly (with -S) and...

    I looked at the generated assembly (with -S) and it has unrolled the loop, but only for 3 iterations. However, just using -funroll-loops doesn't cause the problem.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4