Search:

Type: Posts; User: rstanley

Page 1 of 20 1 2 3 4

Search: Search took 0.04 seconds.

  1. Replies
    17
    Views
    375

    The first line before the loop prints: a Then...

    The first line before the loop prints:
    a

    Then in the loop, it prints the remainder of the arrays, correctly:
    aa
    aaa
    aaaa
    aaaaa
    aaaaaa
    aaaaaaa
  2. Replies
    17
    Views
    375

    Did you run my version? Print the first array...

    Did you run my version?

    Print the first array before the for() loop, then run the loop starting with the second array.
  3. Replies
    17
    Views
    375

    Yes. Normally, for loops are written as...

    Yes.

    Normally, for loops are written as
    for(int i = 0, i < 10; i++)

    But in this case, you might write it as:

    #include <stdio.h>
    #include <string.h>
  4. Replies
    17
    Views
    375

    Why would you assume that? "for(int...

    Why would you assume that?

    "for(int i=0;i<10;i++)"

    Wouldn't i be 0 the first time? In that case, what is i-1?

    i-1 is before the start of the array!
  5. Replies
    17
    Views
    375

    ba is a two dimensional array. 10 arrays of 12...

    ba is a two dimensional array. 10 arrays of 12 chars each. Think in terms of a spreadsheet of 10 rows of 12 fields.
  6. Replies
    17
    Views
    375

    On line 4, the first time through the loop, what...

    On line 4, the first time through the loop, what is the value of i and what is the value of i-1???

    strcpy() copies the string in the previous array to the current array, then the next line appends...
  7. Replies
    3
    Views
    365

    First all, please display plain text of the...

    First all, please display plain text of the source code and results in CODE tags, NOT fuzzy images! Without seeing your actual code, we cannot comment.

    Why does the 8 byte bss segment bother...
  8. Replies
    5
    Views
    634

    It's the compiler that initializes x during the...

    It's the compiler that initializes x during the compile process. Look at the source file and the assembler code:

    Source file:
    int x = 20;

    int main(void)
    {

    return 0;
    }
  9. Replies
    5
    Views
    634

    Global: int x = 20; // Harcoded...

    Global: int x = 20; // Harcoded "Initialization" by the compiler at compile time.

    Global: int x; // Uninitialized global variables are automatically initialized to zero
    Local: x = 20; //...
  10. Many functions return some sort of error/success...

    Many functions return some sort of error/success value that can be checked for success or failure. Those functions that return a regular value, can be checked, again if the value indicates success...
  11. Replies
    12
    Views
    1,008

    When compiling with gcc on Linux, I get the...

    When compiling with gcc on Linux, I get the following errors:

    com bar.c
    bar.c: In function ‘main’:
    bar.c:28:38: error: ‘program_invocation_short_name’ undeclared (first use in this function)
    ...
  12. We would need more information about what you are...

    We would need more information about what you are trying to do. Do you have any code yet?
  13. Thread: A memory leak

    by rstanley
    Replies
    14
    Views
    8,812

    You may also want to check out this latest...

    You may also want to check out this latest article on the Static Code Analysis options being added to gcc 14, or already added to the current gcc compiler.

    Check out all the gcc options,...
  14. Replies
    2
    Views
    628

    This is a forum for the C Programming Language. ...

    This is a forum for the C Programming Language. We cannot give you answers to Windows specific questions.

    You need to post this in the Windows forum on this site.
  15. Replies
    2
    Views
    911

    That would depend on the O/S. Please check this...

    That would depend on the O/S. Please check this article for multiple O/S's.

    Also, you could use ncurses.
  16. Thread: A memory leak

    by rstanley
    Replies
    14
    Views
    8,812

    You are not being "Old Fashioned"! Just stick to...

    You are not being "Old Fashioned"! Just stick to using the Standard C Library and your code will be very portable. Avoid most, if not all of the compiler specific extension functions!


    C is for...
  17. Thread: A memory leak

    by rstanley
    Replies
    14
    Views
    8,812

    Actually, there is one minor correction I would...

    Actually, there is one minor correction I would make besides the my other reccmendations:

    printf("%u is not betweem 1 and %u.\n", count, MAXNUMS);

    // Should be:

    printf("%u is not betweem 1...
  18. Thread: A memory leak

    by rstanley
    Replies
    14
    Views
    8,812

    BillMcEnaney: IMHO, No. splint is...

    BillMcEnaney:



    IMHO, No.

    splint is outdated and has too many "False Positives". Apparently it has not been updated since 2007, prior to the C11 and C17 C Standards were published!
    ...
  19. Replies
    6
    Views
    4,044

    strcat() is a C Standard Library...

    strcat() is a C Standard Library function. As such, the prototype for this and all other C Standard Library functions, will be the same on Windows, Linux, UNIX, MacOS, and all other Standards...
  20. Replies
    6
    Views
    4,044

    Please make sure that you post code that will...

    Please make sure that you post code that will compile on someone else's computer!

    "EMPTY;" should be replaced with a simple standard, ';' Everyone knows what that means!

    $is_null(dst) Not...
  21. Thread: A memory leak

    by rstanley
    Replies
    14
    Views
    8,812

    If you are capturing the output from output...

    If you are capturing the output from output functions just to prevent messages from splint, don't waste your time! use:

    splint -retvalint ./source_file.c

    You should be checking the return...
  22. Thread: A memory leak

    by rstanley
    Replies
    14
    Views
    8,812

    Your "memory leak" is erroneous! If you are on...

    Your "memory leak" is erroneous! If you are on Linux, you could run valgrind. Splint is not that reliable, IMHO. I consider splint report of a memory leak as a false positive.

    I would also...
  23. Replies
    6
    Views
    4,044

    Yes, it is possible. If you are talking...

    Yes, it is possible.

    If you are talking about defining your version of strcat(), how would you approach it? If you didn't use pointers how would you write it? How would you then implement it...
  24. Replies
    6
    Views
    4,044

    Seriously? strcat() does use pointers to both...

    Seriously? strcat() does use pointers to both the source and destination! In a browser enter, "https://man7.org/linux/man-pages/man3/strcat.3p.html" and read the details presented there!
    ...
  25. Replies
    4
    Views
    2,841

    Did you "#include " that declares the...

    Did you "#include <stdio.h>" that declares the function, fileno().
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4