Page 6 of 6 FirstFirst ... 23456
Results 51 to 55 of 55

Thread: Noob Question

                  
   
  1. #51
    DCEmu Old Pro
    Join Date
    Nov 2006
    Posts
    1,011
    Rep Power
    72

    Default

    Find the end of your string using strlen, for example, then assign a null character.


    int string_length = 0;

    char my_string[] = {"boat"};

    printf("%s\n", my_string);

    /* outputs boat */

    string_length = strlen(my_string);

    /*string_length equals 4*/

    my_string[3] = '\0';

    /*insert null character at the end of the string*/

    printf("%s\n", my_string);

    /* outputs boa */

  2. #52
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    87

    Default

    my_string[3] = '\0';

    should be

    my_string[string_length-1] = '\0';

  3. #53
    DCEmu Rookie
    Join Date
    May 2007
    Location
    Under your Bed
    Posts
    168
    Rep Power
    0

    Default

    yes i just figured that out and it WORKS!!! thank you very much!!

  4. #54
    DCEmu Old Pro
    Join Date
    Nov 2006
    Posts
    1,011
    Rep Power
    72

    Default

    Quote Originally Posted by yaustar View Post
    my_string[3] = '\0';

    should be

    my_string[string_length-1] = '\0';
    Thanks for catching my mistake.

  5. #55
    DCEmu Rookie
    Join Date
    May 2007
    Location
    Under your Bed
    Posts
    168
    Rep Power
    0

    Default

    ok now im having ANOTHER problem, im working on the ad-hoc part, and as i have told you i was following this tutorial.
    http://forums.qj.net/f-guides-develo...ial-55788.html
    (right now im using the eboot of this program)it sends the size of the message correctly, but it doesn't send the actual message right. I believe that the problem is that it sends the message as void, but then it doesn't get changed to a string or something, does anyone know how to do this???

Page 6 of 6 FirstFirst ... 23456

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •