Search:

Type: Posts; User: Hodor

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    6
    Views
    242

    What is a "struct call"?

    What is a "struct call"?
  2. Replies
    11
    Views
    287

    ^ this. I think it's also important to note that...

    ^ this. I think it's also important to note that if you compile with optimisation (-O1, -O2 etc, including -Os) gcc doesn't store the string as immediate data. E.g. given:


    #include <stdio.h>
    ...
  3. Replies
    11
    Views
    287

    Thanks for pointing this out. I was of course...

    Thanks for pointing this out. I was of course being deliberately sloppy to make my point but I should have made that clearer in my post. I rarely see somebody write char *str = "Hello"; (i.e. without...
  4. Replies
    11
    Views
    287

    Forget that char *str = "Hello"; /*...

    Forget that



    char *str = "Hello"; /* example 1 */ /*should really be const char *str because modifying the values it points to is naughty */


    is very different to
  5. Thread: School Record

    by Hodor
    Replies
    6
    Views
    290

    I don't know why you'd even try this. Use a...

    I don't know why you'd even try this. Use a database, not C
  6. Thread: HW

    by Hodor
    Replies
    2
    Views
    167

    Why don't you compile it and see? Actually it...

    Why don't you compile it and see?

    Actually it won't display anything at all because the use of "smart" quotes and a missing semicolon means that it won't compile.
  7. Thread: HW

    by Hodor
    Replies
    2
    Views
    196

    Despite this not being a homework service, the...

    Despite this not being a homework service, the question is dumb because two of the answers are correct (assuming you introduced the "smart" ' characters instead of simple ')
  8. Replies
    5
    Views
    400

    The C11 standard would disagree and what gcc does...

    The C11 standard would disagree and what gcc does is immaterial.

    For functions other than main(void) gcc on my system does produce different ASM for fn() and fn(void)

    Edit:



    Therefore...
  9. I wouldn't worry about your age. 25 is pretty...

    I wouldn't worry about your age. 25 is pretty young. I don't know what uni/college is like where you are but here in Australia there are lots of people older than 25 attending even at undergraduate...
  10. Replies
    4
    Views
    294

    The K&R approach is pretty bad, but using conio.h...

    The K&R approach is pretty bad, but using conio.h is arguably worse. At least, as bad as it is, the K&R approach is portable. Try compiling your solution using conio.h using anything but Windows or...
  11. Replies
    4
    Views
    294

    Your printf() is wrong as well. Change to: ...

    Your printf() is wrong as well. Change to:



    printf ("%d\n", *pn);

    return c;

    }
  12. Replies
    4
    Views
    294

    Have you implemented getch() and ungetch()? ...

    Have you implemented getch() and ungetch()?


    Edit: the functions are also provided at the bottom of the first post in this thread: Complex declarations &amp; ?error in Kernighan/Ritchie?
  13. Replies
    10
    Views
    469

    It was late at night and I was merely quoting....

    It was late at night and I was merely quoting. What I meant to write is that int function() is not the same as int function(void) in the current and previous version of the standard.
  14. Replies
    10
    Views
    469

    Strictly speaking void main() is quite different...

    Strictly speaking void main() is quite different to void main(void), as for any other function. The next version of the standard may say that function() is the same as function(void) (it's being...
  15. for (count = 1; count

    for (count = 1; count <= 9; count++) // generate random number loop digit from 0 -> 9
    {
    num = rand() % limit;
    printf("%d", num);
    }




    The code...
  16. Replies
    4
    Views
    402

    @san12345 do you want combinations or...

    @san12345 do you want combinations or permutations?
    @rusyoldguy are you sure your program is complicated enough? Is it the enterprise solution to the problem? Additionally, This is the C sub-forum,...
  17. Replies
    4
    Views
    345

    You don't. The string literal could be constant...

    You don't. The string literal could be constant or non-constant (it's not defined by the C Standard). But treating it as non-constant is undefined behaviour so best to just always treat it as constant
  18. Yes, it's in memory printf("address of...

    Yes, it's in memory



    printf("address of person : %p \n", &person);



    printf("what Ptr points to : %p \n", Ptr);
  19. It's not always necessary to allocate dynamic...

    It's not always necessary to allocate dynamic memory but the pointer has to point to something valid before you use it (called dereferencing). E.g.



    #include <stdio.h>

    #include <stdlib.h>
    ...
  20. Replies
    6
    Views
    486

    I hate VLAs even when they're done "right"

    I hate VLAs even when they're done "right"
  21. Replies
    5
    Views
    567

    I can answer your question very easily (for a...

    I can answer your question very easily (for a start look at line 23 and what the condition is) but I have to wonder what you're trying to achieve. If you're trying to learn programming then, I have...
  22. Another one ticked off the list then ;) You could...

    Another one ticked off the list then ;) You could muck around with lines 30 and 31 because the break isn't 100% necessary because you're checking ctr in the main loop anyway but it's quite readable...
  23. Well, PsychoBandit was polite enough to respond...

    Well, PsychoBandit was polite enough to respond 10 hours ago here : c - I have error in showing the entered Resistor Values at the summary (last part of program) - Stack Overflow

    but haven't seen...
  24. You'll need a count variable as well as 'p'...

    You'll need a count variable as well as 'p' because you don't want to compare the prime number itself ('p') to 'input'. This is because you want to know what the 10001st (for example) prime number...
  25. Replies
    8
    Views
    411

    I hope you're not serious

    I hope you're not serious
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4