Search:

Type: Posts; User: jarro_2783

Search: Search took 0.00 seconds.

  1. I don't know if you actually want to write this...

    I don't know if you actually want to write this or if you just want a parser, but in the latter case you could consider looking at Flex and Bison. They are parser generators and are fairly easy to...
  2. Replies
    8
    Views
    1,228

    it's M_PI

    it's M_PI
  3. well that's handy to know. The pointers will...

    well that's handy to know.

    The pointers will only ever be an array of three or four elements. I'm allocating that with a function (setNumVertices) which allocates the pointers. Then in a loop I...
  4. don't worry, it's more effort than it's worth...

    don't worry, it's more effort than it's worth even if it is possible. I get what you're saying about a third object storing references, that would probably work. But I can just do it with a function...
  5. I didn't think it would work. I was playing...

    I didn't think it would work. I was playing around with it and it wasn't quite working.
    I could just do what you said either with a function of just directly.

    I think you misunderstood my design....
  6. crazy = and [] operator overloading question

    I have two structs:



    struct FaceVertex {
    float u;
    float v;
    int vertex;
    };
  7. Replies
    7
    Views
    1,344

    when to use struct and when to use class?

    If class and struct are exactly the same except that a struct's members are public by default and a class' members are private by default, what is the difference and how do I decide to use one over...
  8. Replies
    18
    Views
    2,480

    also, and are the c and c++...

    also,
    <stdio.h> and <iostream> are the c and c++ versions of console output. You probably only want to use one of those and not both.
  9. Replies
    4
    Views
    1,913

    it still runs: gcc -o birthdays birthdays.o I...

    it still runs:
    gcc -o birthdays birthdays.o
    I don't get it, it should know that it's up to date shouldn't it?
  10. Replies
    19
    Views
    9,820

    that's strange, I can't see why it wouldn't work....

    that's strange, I can't see why it wouldn't work.

    Of course if you are reading multiple things in you will need to keep track of which element in the array you are up to, so you will need to do
    ...
  11. Replies
    19
    Views
    9,820

    you need to do if(fgets(arrayA[0],...

    you need to do



    if(fgets(arrayA[0], sizeof(arrayA[0]), stdin) != NULL)


    because arrayA is type char**, fgets is expecting type char*.
    sizeof(arrayA) will give you the whole 2d array, you...
  12. Replies
    19
    Views
    9,820

    oh yeah, you're right. An interesting thing to...

    oh yeah, you're right.

    An interesting thing to note though, because of the way arrays are stored you get this:



    #include <stdio.h>

    int main(int argc, char **argv) {
  13. Replies
    7
    Views
    1,962

    you even put in your comment //while char is...

    you even put in your comment

    //while char is not '(' and not end of string, increase index

    make it && and it should work.

    Also with this line:

    while( str[index] != '\0' && str[index++]...
  14. Replies
    19
    Views
    9,820

    no that's wrong as well. arrayA[0][0] gives the...

    no that's wrong as well.
    arrayA[0][0] gives the first element, so &arrayA[0][0] just gives the address of the first element.
    *arrayA dereferences the address arrayA points to, which is the first...
  15. Replies
    160
    Views
    1,197,233

    Sticky: We're using "Programming, Problem Solving, and...

    We're using "Programming, Problem Solving, and Abstraction with C" by Alistair Moffat at uni.
    It's extremely good, it is a from scratch book. It has lots of good diagrams and lots of code. It...
  16. Replies
    19
    Views
    9,820

    no that's incorrect. arrayA == &arrayA[0]....

    no that's incorrect.
    arrayA == &arrayA[0].
    also, *(arrayA + 1) == arrayA[1];

    An array is just a pointer to the first element in the array. So *arrayA is the first element.
  17. Replies
    4
    Views
    1,913

    make incorrectly remaking targets

    I have a problem with make, sometimes it remakes targets even when nothing has changed.

    This is the simplest makefile that the problem happens on:



    all: birthdays.o
    gcc birthdays.o...
Results 1 to 17 of 17