Search:

Type: Posts; User: alecodd

Search: Search took 0.01 seconds.

  1. Replies
    33
    Views
    3,527

    i doubt it. k&r is full of initialization of...

    i doubt it. k&r is full of initialization of "automatic" arrays, but i would be happy if somebody will clarify that. thanks
  2. Replies
    33
    Views
    3,527

    well, p (a pointer returned from malloc()) MUST...

    well, p (a pointer returned from malloc()) MUST be cast to the right type if you want to increase p++, otherwise, how is p guaranteed to jump to the next element.
  3. Replies
    33
    Views
    3,527

    yeah, but an array name and a pointer are...

    yeah, but an array name and a pointer are completely different as the second is a variable but not the first. if a is an array defined a[x], a = some_pointer is ILLEGAL.
  4. Replies
    33
    Views
    3,527

    [QUOTE=kliro89;998340]...1...But when I try to...

    [/qutoe]
    Well, malloc is just a generic function that does almost exactly what you've done, you've just done it more explicitly. good on you..
    Generally, malloc will just allocate enough memory...
  5. Replies
    2
    Views
    13,378

    structures are NOT array, so...

    structures are NOT array, so struct-name[position], is wrong.

    besides it is a LINKED list where 1 structure points to another one SINGLE structure, so they are not even "similar" to arrays.
    ...
  6. Replies
    9
    Views
    1,611

    Yes, it doesn't work. but you can press a...

    Yes, it doesn't work.
    but you can press a newline (Enter) and then ctrl-d, generally the operating system sends -1 whenever you send ctrl-d in the beginning of the line.

    So, vote will get the...
  7. Replies
    9
    Views
    1,611

    Your program is "working", althou you failed to...

    Your program is "working", althou you failed to define a return value to main.
    The logic behind the porgram need fixing, for handling space, newline etc. as they get counted for "invalid votes".
  8. Replies
    4
    Views
    1,003

    The value of x is THE ASCII value of the...

    The value of x is THE ASCII value of the character, so for the numbers 0-9 you get actually 48-57, so after you enter 2, for example, you try to access grid[50], which is well beyond the bound of the...
  9. Thread: new to c

    by alecodd
    Replies
    8
    Views
    1,142

    the "logic" is that a function is able to return...

    the "logic" is that a function is able to return only one value, so you have to pass two array pointers, be extremely careful to notice the difference here between passing by value, and by pointer,...
  10. Replies
    38
    Views
    10,197

    Do you konw the basics? Can you compile and...

    Do you konw the basics?
    Can you compile and write by yourself?

    What exactly are you after?

    If you want to study, a reference book will sure do.
    If you want an example code, again, the...
  11. yeah, so it will terminate only if if...

    yeah, so it will terminate only if if number[ball] is zero. i.e. the number did not come up in the draw before.

    ball is an integer, so you always have to get rid of the fraction..so 20/50 = 0;
  12. Replies
    7
    Views
    1,127

    What do you mean by printing the array[10] into...

    What do you mean by printing the array[10] into 5, 10, etc..
    What are you trying to accomplish.

    What are you passing in line 15 or so in the code to printf? "array[10]"?
    The last element is...
  13. Replies
    6
    Views
    1,013

    Ony way is: if (number > 80) statement.. // i.e....

    Ony way is:
    if (number > 80) statement.. // i.e. between 80 and 100
    else if (number > 60) statement.. // i.e. between 60 and 80
    else if(number > 70) statement.. // i.e. between 70 and 80
    else...
  14. Replies
    2
    Views
    774

    In the first program, line 7: the first argument...

    In the first program, line 7: the first argument should be a literal string, so just surround it with a double quote, and you'll be fine.

    Now to the second:
    in line 7, you must separate the...
  15. Thread: Pointers

    by alecodd
    Replies
    20
    Views
    2,117

    You may find it easier to wirte `char **argv',...

    You may find it easier to wirte `char **argv', since this is the way the compiler interprets it anyway.

    You may pretent to pass an array, but it is NOT what you get. You get a pointer, which...
  16. couldn't agree more. just explained where the...

    couldn't agree more.
    just explained where the return value comes from, and yeah, it is an undefined behaviour.
  17. which is the value of i, the last computation...

    which is the value of i, the last computation before the termination of the loop.
    Nothing is necessarily wrong w/ his compiler, just had to compile with warning option/strict mode etc. like you did
  18. Replies
    3
    Views
    2,270

    why not use braces and then it just become a...

    why not use braces and then it just become a block by itself..or is it just another alternative to use without introducing a new scope by a nested block?

    thnaks
  19. Replies
    3
    Views
    2,270

    k&r page 63: comma operator

    can somebody explain to me the meaning of the following paragraph?

    "Comma operators should be used sparingly. The most suitable uses are for constructs strongly related to each other, as...
Results 1 to 19 of 19