#include <stdio.h> void sp_to_dish (const char *str); void main () { sp_to_dish ("this is an apple"); } void sp_to_dish (const char *str) { while (*str) { if (*str == ‘ ‘) printf ("-");//此处不能用*str = "-",会提示错误const定义变量的值无法更改 else printf ("%c",*str); str++; } printf ("\n"); }
原文:http://8102481.blog.51cto.com/8092481/1611604