|
4/4 |
2001/8/27 [Computer/SW/Languages/Perl] UID:22276 Activity:high |
8/27 What is an OS level command equivalent of perl's chomp and chom? \_ /* not tested */ void chomp(char *str) { int len; if (str == NULL || ((len = strlen(str)) <= 0)) return; if (str[len-1] == '\n') str[len-1] = '\0'; } void chop(char *str) { int len; if (str == NULL || ((len = strlen(str)) <= 0)) return; str[len-1] = '\0'; } |