西西河

主题:【原创】如何REVERSE一个C STRING? -- 老成都

共:💬30 🌺11 新:
全看分页树展 · 主题 跟帖
家园 I test it already.Notice:

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.

全看分页树展 · 主题 跟帖


有趣有益,互惠互利;开阔视野,博采众长。
虚拟的网络,真实的人。天南地北客,相逢皆朋友

Copyright © cchere 西西河