A problem about strings
#6

Why would you want to clear the entire string? Just end the string once you are done replacing characters.

pawn Код:
new x[16];
    x[0] = '1';
    x[1] = '2';
    x[2] = '3';
    x[3] = '4';
    x[4] = '5';
    //Expected result of x: "5 12345", actual result: "5 12345"
    printf("%d %s",strlen(x),x);
    x[0] = '2';
    x[1] = '3';
    x[2] = '4';
    x[3] = '\0';
    //Expected result of x: "3 234", actual result: "3 234"
    printf("%d %s",strlen(x),x);
Reply


Messages In This Thread
A problem about strings - by leong124 - 07.12.2011, 13:34
Re: A problem about strings - by TheArcher - 07.12.2011, 13:36
Re: A problem about strings - by leong124 - 07.12.2011, 13:39
Re: A problem about strings - by TheArcher - 07.12.2011, 13:41
Re: A problem about strings - by leong124 - 07.12.2011, 14:10
Re: A problem about strings - by JamesC - 07.12.2011, 14:19
Re: A problem about strings - by leong124 - 07.12.2011, 14:24
Re: A problem about strings - by cessil - 07.12.2011, 14:54
Re: A problem about strings - by cod4esle - 07.12.2011, 14:55
Re: A problem about strings - by leong124 - 07.12.2011, 15:49

Forum Jump:


Users browsing this thread: 9 Guest(s)