Re: [問題] const的問題
#include <stdio.h>
void function(const char *str, int i)
{
printf("%s %d\n", str, i);
}
int main()
{
const char *input = "12pp";
char output[32];
int i, j;
for (i = 0, j = 0; i < strlen(input); i++)
{
if (!isdigit(input[i]))
{
output[j] = input[i];
j++;
}
}
output[j] = '\0';
function(output, strlen(output));
}
比較簡單的寫法大概像這樣子
如果有哪裡不懂,可以先查查手邊的書籍,或者 google 查查資料
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.117.171.46
→
12/02 19:18, , 1F
12/02 19:18, 1F
推
12/02 19:33, , 2F
12/02 19:33, 2F
→
12/02 19:36, , 3F
12/02 19:36, 3F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):
3
12
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章