主题:【原创】如何REVERSE一个C STRING? -- 老成都
you need to pass a char[], you can not pass "hello the world" directly, you need to scan a string to a char buffer.
My environment is gcc/Linux.
Do you kown the difference for "char *p="hello the world" and the "char p[100]"?
My test code is something like
"
main()
{
char str[100],
scan("%s",str);
printf("original:%s\n",str);
reverse(str);
printf("reversed:%s\n",str);
}
"
It works fine. I guess you pass "hello the world" directly into the reverse function.
- 相关回复 上下关系7
🙂有道理!花 无斋主人 字31 2007-03-29 19:09:45
🙂这个当然是工作过的人的标准答案,没另外用个 老成都 字146 2007-03-29 18:51:37
🙂Does it really work? bigbug 字247 2007-02-23 20:26:39
🙂I test it already.Notice:
🙂这个方法好。花 rtf0 字0 2007-02-19 19:50:16
🙂各路高手们,帮帮忙啊?俺挨个送花:),发言就有花! 老成都 字0 2007-02-18 17:09:30
🙂找了一下,网上的答案大多是错的. 老成都 字0 2007-02-18 17:02:51