If you don’t need to copy the line somewhere else and you can change it
namelen = strlen(name);
name[namelen - 3] = 0;
If you need to copy it (because it is a string literal or you want to keep the original)
namelen = strlen(name);
strncpy(copy, name, namelen - 3);
copy[namelen - 3] = 0;
source
share