文件分類 [Browse all]
社群資訊
Guests: 2021695
Articles: 557
Comments: 1315
Announcements: 31
Free Quota: 2.4 GB (4 GB)
Guest Access: Open
Category: 教育學習 / 軟體系統
Vice Webmaster: None
移除字串的"空白字元"
by 艾鍗學院, 2013-11-28 15:14, Views(936)
作業: 寫一個函式, 移除字串末端的"空白字元" , 並傳回移除後的字串長度
作業解答:
static int rtrim(char *s)
{
int i;
for (i = strlen(s) - 1; i >= 0 && (s[i] == ' ' || s[i] == '\n'); i--)
s[i] = '\0';
return i + 2;
}