How do I remove the file Extension from a string?
#8

pawn Код:
main() {
    // test
    new path[] = "path/to/file/with.periods.ext";
    remove_extension(path);
    printf("path = %s", path);
}

stock delete_extension(path[]) {
    new i = -1, j;
    // Loop until find the last '.'
    while ((j = strfind(path, ".", _, i + 1)) != -1) {
        i = j;
    }
    // Delete .extension
    strdel(path, i, i + strlen(path[i]));
}
Reply


Messages In This Thread
How do I remove the file Extension from a string? - by Sasino97 - 21.10.2011, 14:15
Re: How do I remove the file Extension from a string? - by Max_Coldheart - 21.10.2011, 14:26
Re: How do I remove the file Extension from a string? - by CyNiC - 21.10.2011, 14:30
Re: How do I remove the file Extension from a string? - by Sasino97 - 21.10.2011, 14:48
Re: How do I remove the file Extension from a string? - by Max_Coldheart - 21.10.2011, 14:49
Re: How do I remove the file Extension from a string? - by CyNiC - 21.10.2011, 15:02
Re: How do I remove the file Extension from a string? - by Vince - 21.10.2011, 15:17
Re: How do I remove the file Extension from a string? - by 0x5A656578 - 21.10.2011, 15:19
Re: How do I remove the file Extension from a string? - by CyNiC - 21.10.2011, 15:28
Re: How do I remove the file Extension from a string? - by Sasino97 - 21.10.2011, 18:40

Forum Jump:


Users browsing this thread: 1 Guest(s)