标题:字符串wordwrap问题。
取消只看楼主
winglesswu
Rank: 1
等 级:新手上路
帖 子:92
专家分:0
注 册:2013-1-28
结帖率:71.88%
已结贴  问题点数:10 回复次数:1 
字符串wordwrap问题。
编写一个程序,要求把用户输入的字符串按照要求输出,比如:
char s[ ] = "My home is in Toronto    Ontario";
 int i;

 i =  wordWrap(s, 7);
 printf("%d\n%s\n",i s);
调用函数后输出:
4
 My home
 is in
 Toronto
 Ontario
下面是小弟写的,请指点,谢谢。
#include<stdio.h>
/*wordwrap*/
main()
{

char s[ ];
int i;

printf("Please enter the string you want to do wordwrap:\n");
scanf("%s", s);

i =  wordWrap(s, 7);
printf("%d\n%s\n", i, s);
 }
 int wordWrap( char s[ ], int width )
 {
  int x, y;
  for (x=0; x<width; x++)
  {
  printf("s[x]");
  if (x%7==0)
  printf("\n");
  }
  y=width/7
  return y;
 }
 }
搜索更多相关主题的帖子: include 字符串 用户 
2013-04-10 11:21
winglesswu
Rank: 1
等 级:新手上路
帖 子:92
专家分:0
注 册:2013-1-28
得分:0 
我的机器上gets()用不了。
2013-04-11 11:25



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-403582-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 2.286155 second(s), 10 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved