Search:

Type: Posts; User: acpower

Search: Search took 0.01 seconds.

  1. Replies
    2
    Views
    916

    Printing multiplcation table

    I would like to print a multiplication table, with the dimension n given as input. I attached how the table looks like for n=7.

    How do you output the character "-" in that sequence? The first and...
  2. Replies
    1
    Views
    1,422

    Please ignore this as I've found the others. ...

    Please ignore this as I've found the others.

    malloc wasn't checked to see if it returned a NULL pointer and line 17 should be
    "list->next != NULL".
  3. Replies
    1
    Views
    1,422

    identify bug in code

    List points to the first element in the list.
    All the nodes is intended to be allocated with malloc.

    The task is to insert the integer toinsert into the list before the node containing before....
  4. Replies
    2
    Views
    673

    allocating new objects

    A programmer thinks dynamic memory management is too fragile and subject to memory leaks, and prefers the following way of allocating new objects:


    typedef struct {

    int year;
    int month;
    int...
  5. Replies
    8
    Views
    1,534

    Hang on, if y was incremented twice how come for...

    Hang on, if y was incremented twice how come for inputs x=2,y=3, y is 4 and not 5? Why was y incremented twice for y=-2 (to get zero) but not for y=3?
  6. Replies
    8
    Views
    1,534

    oops thanks!

    oops thanks!
  7. Replies
    8
    Views
    1,534

    @anduril462: I've already tried this by hand,...

    @anduril462: I've already tried this by hand, first thing I did. And I've made many attempts, ran the code etc
  8. Replies
    8
    Views
    1,534

    I have one more of these: #include...

    I have one more of these:



    #include <stdio.h>


    #define min(a,b) ((a) > (b) ? (b) : (a))
    #define inc(a) a++
    #define mult(a,b) (a * b)
  9. Replies
    8
    Views
    1,534

    macro definitions problem

    #include <stdio.h>
    #define next(x) x+1
    #define max(x,y) x >= y ? x : y


    int a = ..;
    int b = ..;
    void main(void) {
  10. Replies
    5
    Views
    1,640

    identify problems with code

    Suppose you have a list defined by the following type, in which every node is intended to be allocated by malloc:



    typedef struct intlist_struct intlist_t;

    struct intlist_struct {
    ...
  11. Replies
    5
    Views
    888

    Yes they are.

    Yes they are.
  12. Replies
    2
    Views
    1,265

    thanks for that. i visited Stack (abstract data...

    thanks for that. i visited Stack (abstract data type) before but this page is much better.
  13. Replies
    2
    Views
    1,265

    function calls and return address

    Suppose function f calls function g, which in turn calls other functions. How does function g know where it should return to when its task is done?

    I know a stack space is created at every...
  14. Replies
    8
    Views
    1,083

    :D Just to be extra sure.....malloc will stay...

    :D

    Just to be extra sure.....malloc will stay for the duration of the program until it's "freed" right?

    And you would do it like this:



    int *sort_array;
  15. Replies
    8
    Views
    1,083

    Then how do I return an array??? :S I have to...

    Then how do I return an array??? :S

    I have to pass a pointer from main??? There has to be another way....
  16. Replies
    8
    Views
    1,083

    returning pointer to an array

    My function prototype is:


    int* sort_leaders(int , int , int *, unsigned int);

    I have an array called "sort_array[10]" that I want to return.

    I do this by simply putting at the end of the...
  17. Replies
    2
    Views
    894

    That's how the code was given to us. But anyway I...

    That's how the code was given to us. But anyway I think I got it, I'll see how it goes.
  18. Replies
    2
    Views
    894

    Pointer to a pointer struct

    I'm working on a project that involves double pointers INSIDE a struct, and I'm kinda confused.


    typedef struct block {

    unsigned int start_address;
    unsigned int...
  19. Replies
    5
    Views
    1,971

    yeah i just tried that. thanks.

    yeah i just tried that. thanks.
  20. Replies
    5
    Views
    1,971

    logical operator

    if ( opcode == (0x0) || (0x1)|| (0x2) || (0x4)|| (0x6)|| (0x1)) {

    //blah


    }

    I get a warning saying: Use of logical "||" with constant operand. ...
  21. Replies
    2
    Views
    5,062

    Read inputs separated by space

    If I am reading input from a file such as


    1 2 3 4 5

    How do I get my program to register each number as separate input?

    Thanks
Results 1 to 21 of 21