以“|”为标志,进行换行显示如下格式信息“123|456|789” #include <stdio.h> #include <string.h> #include <unistd.h> #include<sys/types.h> #include<sys/stat.h> #include<fcntl.h> #include<stdlib.h> main() { char prnstr[20]; memset(prnstr,0,20); char *temp=NULL; char aa[]="123|456|789|"; temp = aa; printf("[%s]/n",temp); while(*temp) { printf("the value is [%c]/n",*temp); if(*temp=='|') { sprintf(prnstr,"%s/n",prnstr); temp++; continue; } else sprintf(prnstr,"%s%c",prnstr,*temp); temp++; } printf("/nprnstr is [%s]/n",prnstr); }