Search:

Type: Posts; User: Adam Rinkleff

Page 1 of 4 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    4
    Views
    2,814

    I might have just fixed it by changing this line:...

    I might have just fixed it by changing this line: [Items*new=(Items*)malloc(sizeof(Items*));} to



    Items*new=(Items*)malloc(sizeof(Items));


    Could someone explain how exactly my code is...
  2. Replies
    4
    Views
    2,814

    I changed the code slightly: ...

    I changed the code slightly:

    new->loc=&a[currentarea]; printf("%s", new->name);
    new->prev=NULL; printf("%s", new->name);
    new->next=NULL; printf("%s", new->name);


    If the name is...
  3. Replies
    4
    Views
    2,814

    strtok(), strdup() error

    I don't really know how to even begin solving this problem. Basically, I have a structure:



    struct Items{
    char*desc;
    char*name;
    char*behave;
    struct Areas*loc;
    struct Items*next;
  4. Laserlight is the best programmer in the whole...

    Laserlight is the best programmer in the whole world!
  5. Wow! They both work, hm. I'm not even sure why...

    Wow! They both work, hm. I'm not even sure why new = malloc(sizeof(*new)); would work, how does it know what the size of new is supposed to be, if it doesn't know its an area*? I guess I don't really...
  6. I added the following line to the end of the for...

    I added the following line to the end of the for loop



    if(i>1){printf("[[::%p::]]", new->prev->prev);}


    This shows that the pointer value is switching to ox11 at the end of each pass. But...
  7. Why are these pointers suddenly changed?

    I created a series of linked lists and then printed them. Notice that I touch new->prev one time, and I verify it has been set via printf at the end of the for loop. However, when I then print all...
  8. Oh, I don't think I need the while(1) at all, its...

    Oh, I don't think I need the while(1) at all, its just not necessary.

    This is what I want:


    void printnode(Area*current){
    printf("\n<%d||[%p]>: <%p|%p>\n", current->name, current,...
  9. break; was only there because return; wasn't...

    break; was only there because return; wasn't working. I can take the break out but nothing changes.
  10. Stuck in simple while loop, can't break or return?

    void printnode(Area*current){
    while(1){
    if(current->next==NULL){printf("[%p]", current->next); return;}
    if(current->next!=NULL){printnode(current->next);}
    }
    }


    In this while loop, as I...
  11. Replies
    4
    Views
    1,201

    oh... that might be it actually... thanks! ill...

    oh... that might be it actually... thanks! ill have to try and see if i can fix it now.
  12. Replies
    4
    Views
    1,201

    i have no idea what's wrong

    I have this section of code. Basically it uses fgets to read from a file, and at the end it does this:



    new->name=name;
    a[currentarea].items=new; ...
  13. struct Areas{ char desc[255]; char name[255];...

    struct Areas{
    char desc[255];
    char name[255];
    struct Items*items;
    int n,s,w,e,u,d;
    };


    struct Items{
    char*desc;
  14. I don't know, I thought I have defined these...

    I don't know, I thought I have defined these structs. The error seems to be that it isn't properly defined. I tried what itCbitC said, but the following still gives the same errors:



    typedef...
  15. structures: dereferencing pointer to incomplete type

    I'm trying to make this basic 'MUD' style game to practice coding, the problem I was having was trying to have two structure types, each of which can contain a pointer to the other type. After I...
  16. Thanks! The following seems to work just fine: ...

    Thanks! The following seems to work just fine:



    printf("Number: %s\n", new->number);
  17. It should look like this: ---------------Top...

    It should look like this:

    ---------------Top of the Screen------------------


    Enter Command:


    Instead I get:
  18. Why is system("clear") executing prematurely?

    In input(), system("clear") executes first in a while loop, and then add(); is called... however, before add(); finishes and returns to input(), system("clear"); is called again and executes in the...
  19. Replies
    2
    Views
    1,970

    Oh, I think I know... I need: ...

    Oh, I think I know...

    I need:

    strcpy(new->name, input);


    :D
  20. Replies
    2
    Views
    1,970

    incompatible types in assignment

    Why might this be: incompatible types in assignment

    Here is my struct:



    typedef struct{
    char name[250];
    char number[10];
    } List;
  21. Replies
    20
    Views
    11,609

    Obviously, I just did, which is why I said it...

    Obviously, I just did, which is why I said it seemed a lot easier -- how about we assume that if I see a line of code, I do try it -- and if I hear about a function, I probably go and look it up......
  22. Replies
    20
    Views
    11,609

    Oh, I was trying *X, *p[0], but going back to...

    Oh, I was trying *X, *p[0], but going back to post #10 -- why use memcpy at all if I can just use what AndrewHunter suggested?
  23. Replies
    20
    Views
    11,609

    That seems a lot easier, why then would I ever...

    That seems a lot easier, why then would I ever want to use memcpy instead of that?
  24. Replies
    20
    Views
    11,609

    I did try it: incompatible type for...

    I did try it:


    incompatible type for argument 1 of `memcpy'
    incompatible type for argument 2 of `memcpy'
  25. Replies
    20
    Views
    11,609

    sizeof(p[0]) is 35024, is that the size of the...

    sizeof(p[0]) is 35024, is that the size of the structure regardless of the values within it, or do those change?


    Should I just do:


    memcpy ( X, p[0], sizeof(p[0]));
    ?

    Yah I guess that...
Results 1 to 25 of 78
Page 1 of 4 1 2 3 4