Thread: Lost, need help again~

  1. #16
    Stressed Student :(
    Join Date
    Feb 2008
    Location
    Berkeley, CA
    Posts
    73
    I've made it compile with the test file, and it gave me this

    You wake up.
    you are in room #0
    There is an exit to the east.

    there seems to be a white space on the output, i'm gonna do a printf on the room_idx, brb

  2. #17
    uint64_t...think positive xuftugulus's Avatar
    Join Date
    Feb 2008
    Location
    Pacem
    Posts
    355
    Quote Originally Posted by NoobieGecko View Post
    thats the right output, thanks xuft, but the problem i'm having now is a segfault, and when i run gdb and i backtrace, i pick up this

    Code:
           room_array[room_idx].description = malloc(strlen(c)-1);
    Sorry very much check my previous post. I had mad a typo, which compiled on my machine and din't segfault....
    Code:
    ...
        goto johny_walker_red_label;
    johny_walker_blue_label: exit(-149$);
    johny_walker_red_label : exit( -22$);
    A typical example of ...cheap programming practices.

  3. #18
    Stressed Student :(
    Join Date
    Feb 2008
    Location
    Berkeley, CA
    Posts
    73
    i checked, the range, it was from 0-25 which is num_rooms-1, i'll have to check the other files, maybe it's doing an error there

  4. #19
    Stressed Student :(
    Join Date
    Feb 2008
    Location
    Berkeley, CA
    Posts
    73
    ah xuftugulus u are awesome! what does strdup(c) do?

    u see i've actually had it right the first night i wrote the code (day 1), but i didn't know about the -> when its in nested pointers, so i did it with **,and since i had a programming problem midway i thought i was completely wrong and scrapped it =\

    thanks^(n!)

  5. #20
    Stressed Student :(
    Join Date
    Feb 2008
    Location
    Berkeley, CA
    Posts
    73
    oh, and also, "0" zero is actually '\0' and i dont have to use the \'s? is that right?

    i'll be starting on the next part, can i ask u further questions when i get stuck?
    Last edited by NoobieGecko; 02-17-2008 at 02:04 AM.

  6. #21
    uint64_t...think positive xuftugulus's Avatar
    Join Date
    Feb 2008
    Location
    Pacem
    Posts
    355
    Quote Originally Posted by NoobieGecko View Post
    oh, and also, "0" zero is actually '\0' and i dont have to use the \'s? is that right?

    i'll be starting on the next part, can i ask u further questions when i get stuck?
    Sure in the meantime i made the go() function and will be playing game. :P

    Declared as:
    char *strdup(char *s);

    It allocates the memory copies the string and returns you the pointer to the copy.
    Just remeber the memory must freed by you then, so that pointer must not be used in pointer arithmetic, or free() will make the program crash.

    0 and '\0' are usually the same value. I don't know of any encoding where the character '\0' doesn't evaluate to 0, and so since a single character is an integral value you can assign a plain 0 to it, although i usually assign a '\0' to remind me that it is a character.
    Sorry for the confusion on this, but i just wrote the code fast and a little careless...
    Last edited by xuftugulus; 02-17-2008 at 02:16 AM.
    Code:
    ...
        goto johny_walker_red_label;
    johny_walker_blue_label: exit(-149$);
    johny_walker_red_label : exit( -22$);
    A typical example of ...cheap programming practices.

  7. #22
    Stressed Student :(
    Join Date
    Feb 2008
    Location
    Berkeley, CA
    Posts
    73
    i'm just about reading the spec -_-

  8. #23
    uint64_t...think positive xuftugulus's Avatar
    Join Date
    Feb 2008
    Location
    Pacem
    Posts
    355
    Quote Originally Posted by NoobieGecko View Post
    i'm just about reading the spec -_-
    Damn i have to get to level 2 to continue...
    That means i have to code the monster functions, to hack some experience.
    Code:
    ...
        goto johny_walker_red_label;
    johny_walker_blue_label: exit(-149$);
    johny_walker_red_label : exit( -22$);
    A typical example of ...cheap programming practices.

  9. #24
    Stressed Student :(
    Join Date
    Feb 2008
    Location
    Berkeley, CA
    Posts
    73
    hah, i didn't get the joke just kidding

  10. #25
    Registered User
    Join Date
    Jul 2009
    Posts
    2
    NoobieGecko, i know it's been a while since this post was touched, but are you still around? can you PM me?

  11. #26
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    This counts as bumping a thread, since posting in any thread older than 2 weeks old counts as bumping. If you want to contact the OP, PM them yourself.

    I don't think you'll have any luck, though, since NoobieGecko's profile page says this:
    # Last Activity: 10-12-2008 02:43 AM
    If you have a similar question, consider starting a new thread but linking to this old one. As it is, that's probably what will end up happening anyway since a moderator will likely split this one.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  12. #27
    Registered User
    Join Date
    Jul 2009
    Posts
    2
    Quote Originally Posted by dwks View Post
    This counts as bumping a thread, since posting in any thread older than 2 weeks old counts as bumping. If you want to contact the OP, PM them yourself.

    I don't think you'll have any luck, though, since NoobieGecko's profile page says this:


    If you have a similar question, consider starting a new thread but linking to this old one. As it is, that's probably what will end up happening anyway since a moderator will likely split this one.
    ah, thanks for telling me. i don't have perms to PM, otherwise i would. probably because i'm a new user?

  13. #28
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Right. Didn't think of that. Yes, it's because you have less than a certain threshold of posts. I'm not sure exactly what the number is.

    Seriously, though. You're not going to get a response from NoobieGecko. If you have a question, post it.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. (Date dt)??? I'm lost...
    By patricio2626 in forum C++ Programming
    Replies: 3
    Last Post: 06-24-2006, 11:49 AM
  2. I lost my laptop, DVD and money
    By Sang-drax in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 10-01-2004, 07:13 PM
  3. lost disk
    By Benzakhar in forum Linux Programming
    Replies: 7
    Last Post: 01-11-2004, 06:18 PM
  4. Lost ID number
    By ripper079 in forum C++ Programming
    Replies: 13
    Last Post: 10-04-2002, 12:51 PM
  5. API, LOST... help
    By Unregistered in forum Windows Programming
    Replies: 5
    Last Post: 03-13-2002, 03:19 PM