d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Keeps Printing Memory Address?
Prev12
Add Reply New Topic New Poll
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Apr 1 2013 11:15pm
Quote (lopelurag @ Apr 2 2013 12:55am)
Yea I did design it that way, some reason wasn't working so I just wanted to make sure.

I'll keep tweaking ty


what is not working about it?

try using printf() with the %p flag and supply your pointer->parent (casted as (void*) for %p) and then also print the child node or w/e idk.

but anyways print the addresses that you are changing before and after and see what they are being set to is what im trying to get at.
Member
Posts: 24,101
Joined: Nov 8 2007
Gold: 5,561.70
Apr 1 2013 11:22pm
Quote (AbDuCt @ Apr 2 2013 01:15am)
what is not working about it?

try using printf() with the %p flag and supply your pointer->parent (casted as (void*) for %p) and then also print the child node or w/e idk.

but anyways print the addresses that you are changing before and after and see what they are being set to is what im trying to get at.


Yea I printed the statements, files->name prints the correct name of the current node, it just doesn't seem to change *files to that position when it exits the function

The return type of the functions an int, but that shouldn't really matter, files should still now point at sub_dir

Code
sub_dir = files->sub_dir;
 while(sub_dir != NULL){
   printf("in");
   if(strcmp(sub_dir->dir_name, arg) == 0){
     printf("in 2");
     files = sub_dir;
     printf("%s", files->name);
     return 0;
   }
   printf("out");
   sub_dir = sub_dir->next;
 }


This post was edited by lopelurag on Apr 1 2013 11:22pm
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Apr 1 2013 11:51pm
Quote (lopelurag @ Apr 2 2013 01:22am)
Yea I printed the statements, files->name prints the correct name of the current node, it just doesn't seem to change *files to that position when it exits the function

The return type of the functions an int, but that shouldn't really matter, files should still now point at sub_dir

Code
sub_dir = files->sub_dir;
 while(sub_dir != NULL){
   printf("in");
   if(strcmp(sub_dir->dir_name, arg) == 0){
     printf("in 2");
     files = sub_dir;
     printf("%s", files->name);
     return 0;
   }
   printf("out");
   sub_dir = sub_dir->next;
 }


im not good with solving these with just snippets i like to go through the code in the debugger line by line so i can see it running.

try doing this

Code
sub_dir = files->sub_dir;
printf("%p\n", (void*)files->sub_dir);

// code
sub_dir = sub_dir->next;
printf("%p\n", (void*)sub_dir->sub_dir);


or w/e and see if the actual address changed to the next address. or something like that. basically confirm that it is indeed changing to the next address.
Go Back To Programming & Development Topic List
Prev12
Add Reply New Topic New Poll