Search:

Type: Posts; User: erikkonstas

Search: Search took 0.01 seconds.

  1. Replies
    4
    Views
    808

    Why would it? You're not assigning anything,...

    Why would it? You're not assigning anything, you're just doing the subtractions.
  2. Replies
    4
    Views
    808

    That's not a zero, that's the character code of...

    That's not a zero, that's the character code of '0', which in ASCII is 48, and all of the digits are in order ('1' is 49, '2' is 50, ..., '9' is 57). To append a digit to tmp, you multiply it by 10...
  3. Replies
    4
    Views
    1,001

    To add to Salem's post, the "int a[n]" syntax...

    To add to Salem's post, the "int a[n]" syntax creates what is known as a Variable-Length Array (VLA) which is not necessarily supported (you can read more about possible shortcomings here).
    ...
  4. Replies
    4
    Views
    2,774

    Another way to tackle the scanf problem is to add...

    Another way to tackle the scanf problem is to add a space after "%d", so this


    scanf("%d", &age);

    turns into this


    scanf("%d ", &age);
  5. Replies
    7
    Views
    2,858

    head isn't a PPMHead, but an array of PPMHead....

    head isn't a PPMHead, but an array of PPMHead. You have to initialize each element of head separately (that is, the members of head[0], the members of head[1], etc.), and in a function (not outside...
  6. Replies
    7
    Views
    2,858

    Initializing a struct means initializing each of...

    Initializing a struct means initializing each of its members, for example:


    #include <stdio.h>

    typedef struct
    {
    int x;
    int y;
    int z;
  7. Replies
    7
    Views
    2,858

    I can see that you're using head[0].width and...

    I can see that you're using head[0].width and head[0].height without initializing head, which means they're always zero, as head is global. This means that your loops do not execute even a single...
  8. By the way, the two output sides might be...

    By the way, the two output sides might be different, but they will always be the same every time the program is ran if you don't use srand. For example, in my case, your original code output Tails...
  9. Replies
    9
    Views
    7,330

    Um I didn't say anything different than john.c...?

    Um I didn't say anything different than john.c...?
  10. Replies
    9
    Views
    7,330

    Yes, in fact, global variables are stored in a...

    Yes, in fact, global variables are stored in a separate part of memory on their own. Note that a global variable isn't the only kind of "a variable that will not get destroyed", but it's the only...
  11. Replies
    9
    Views
    7,330

    Nope. You have to declare it with extern in every...

    Nope. You have to declare it with extern in every compiled file (after preprocessing, so if you just declare it in a header you include in every file, you're OK).
  12. Replies
    5
    Views
    4,507

    I can, too!

    I can, too!
  13. Replies
    6
    Views
    4,948

    Nope, everything should be an int here,...

    Nope, everything should be an int here, especially since % is used.
  14. Replies
    8
    Views
    5,195

    Hm, I wanted to emphasize laserlight's point...

    Hm, I wanted to emphasize laserlight's point above; you do not want to compute the file size beforehand! Who knows what your function will accept as its argument? What if it receives STDIN, for...
  15. Hm, can you mention why you'd want to do this?...

    Hm, can you mention why you'd want to do this? The text "width" you're talking about depends completely on the font the text is written in; for example, on a terminal, the font will most likely be...
  16. Depending on how the "array" is declared, it can...

    Depending on how the "array" is declared, it can also mean that what you pass to sizeof might be a pointer so it returns that size, not the array's! We really need to see more code to be sure what's...
  17. Can you clarify this, please? I can't understand...

    Can you clarify this, please? I can't understand exactly what you want to do.
  18. Replies
    7
    Views
    7,344

    Hi, can you show what you've done so far? We...

    Hi, can you show what you've done so far? We don't generally do other peoples' homework entirely.
  19. Replies
    6
    Views
    5,267

    Yep, that's exactly my point about Sedgewick. So...

    Yep, that's exactly my point about Sedgewick. So I checked again, we're actually using the THIRD edition at university, and the thing where the text and the code differ a lot semantically is very...
  20. Replies
    6
    Views
    14,215

    On top of that, it appears that you've copied...

    On top of that, it appears that you've copied your code incorrectly here, because I can see a missing ) on line 29.
  21. Replies
    6
    Views
    5,267

    Yeah... I happen to be experiencing Sedgewick's...

    Yeah... I happen to be experiencing Sedgewick's snippets from this very book (second edition, current university professor is using it) and his coding style is HORRENDOUS!!! Globals everywhere (in...
  22. Replies
    5
    Views
    6,690

    1. argv is actually an array of pointers to char...

    1. argv is actually an array of pointers to char (char *), the first of which is at the memory address in the argv variable itself, which is why you're "requesting another pointer". Each of these...
  23. I want to point out that setting i to values...

    I want to point out that setting i to values above 0 does actually do something bad in your case: if your string's length is less than the initial value of i, you will be accessing memory you...
  24. Hm, bummer. I was trying to write some test...

    Hm, bummer. I was trying to write some test project which has a lot of functions and decided to split them in a few .c files but I guess I'll have to do either of these two. Thanks for answering,...
  25. "External" linkage between some files but "internal" linkage to the outside world

    Let's say I have a file f1.c with the following:
    int two(int a, int b) {
    return a + b;
    }And a file f1.h with the following:
    int two(int, int);And a file f2.c with the following:
    #include...
Results 1 to 25 of 25