Search:

Type: Posts; User: rstanley

Page 1 of 20 1 2 3 4

Search: Search took 0.05 seconds.

  1. Replies
    6
    Views
    461

    You have no error checking for the length of the...

    You have no error checking for the length of the string and the size of the array.

    A better way of doing this, providing some error checking in the actual code:


    #include <stdio.h>

    int...
  2. Replies
    43
    Views
    1,809

    Salem's code was wrong. She admitted it. I...

    Salem's code was wrong. She admitted it. I don't know what you mean by "looks more construct".
  3. Replies
    43
    Views
    1,809

    I gave you two different solutions that work, but...

    I gave you two different solutions that work, but you keep going back to code that is wrong!
  4. Replies
    43
    Views
    1,809

    It may seem to work, but you are accessing an...

    It may seem to work, but you are accessing an array OUTSIDE of the defined array!!!

    chara[-1] WRONG!!!!!
  5. Replies
    43
    Views
    1,809

    for(i=0;i

    for(i=0;i<10;i++){
    strcpy(chara[i],chara[i-1]);
    strcat(chara[i],"a");
    }

    The first time through the loop, i == 0, and i - 1 IS -1!!!

    I don't understand how this works! It is wrong...
  6. Replies
    43
    Views
    1,809

    WaterSerpentM: The following is an alternative...

    WaterSerpentM:

    The following is an alternative method for displaying what you wanted. It eliminates the need for both strcpy(), and strcat() functions!

    Study it carefully.


    #include...
  7. Replies
    43
    Views
    1,809

    It should be quite obvious with the code and the...

    It should be quite obvious with the code and the results:

    array[0] is set to "a" using strcpy()
    print array[0]

    for() loop:
    strcpy() is used to copy from arrray[0] to array[1]
    then strcat()...
  8. Replies
    43
    Views
    1,809

    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
  9. Replies
    43
    Views
    1,809

    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.
  10. Replies
    43
    Views
    1,809

    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>
  11. Replies
    43
    Views
    1,809

    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!
  12. Replies
    43
    Views
    1,809

    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.
  13. Replies
    43
    Views
    1,809

    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...
  14. Replies
    3
    Views
    709

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

    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;
    }
  16. Replies
    5
    Views
    1,042

    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; //...
  17. 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...
  18. Replies
    12
    Views
    1,375

    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)
    ...
  19. 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?
  20. Thread: A memory leak

    by rstanley
    Replies
    14
    Views
    9,291

    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,...
  21. Replies
    2
    Views
    668

    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.
  22. Replies
    2
    Views
    983

    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.
  23. Thread: A memory leak

    by rstanley
    Replies
    14
    Views
    9,291

    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...
  24. Thread: A memory leak

    by rstanley
    Replies
    14
    Views
    9,291

    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...
  25. Thread: A memory leak

    by rstanley
    Replies
    14
    Views
    9,291

    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!
    ...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4