#include <string.h>
#include <stdio.h>int main(){ char filename[100] = "text.txt"; char *ext = strrchr(filename, '.'); if (ext) { *ext = '\0'; ext++; } printf("name=%s\n", filename); printf("ext-name=%s\n", ext); return 0;}本文共 278 字,大约阅读时间需要 1 分钟。
#include <string.h>
#include <stdio.h>int main(){ char filename[100] = "text.txt"; char *ext = strrchr(filename, '.'); if (ext) { *ext = '\0'; ext++; } printf("name=%s\n", filename); printf("ext-name=%s\n", ext); return 0;}转载于:https://www.cnblogs.com/fengliu-/p/7381551.html