找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2852|回复: 2

[通用编程] 求字符个数问题

[复制链接]
发表于 2007-4-24 16:36:57 | 显示全部楼层 |阅读模式
程序如下:
  1. #include"stdio.h"
  2. main()
  3. {
  4.     void strle(char *p);
  5.     char array[10];
  6.     gets(array);
  7.     strle(array);
  8. }
  9. void strle(char *p)
  10. {
  11.     int i=0;
  12.     char *p1;
  13.     for(p1=p;p1!='\0';p1++)
  14.     i++;
  15.     printf("the answer is %d\n",i);
  16. }
复制代码

为什么这样做错呢,请问应该怎么写才正确呢? [s:5]
发表于 2007-4-24 17:43:14 | 显示全部楼层
#include<stdio.h>

void main()
{
  void strle(char *p);
  char array[10];
  gets(array);
  strle(array);
}
void strle(char *p)
{
  int i=0;
  char *p1=p;
  for(*p1=*p;*p1!='\\0';*p1++)
     i++;
  printf("the answer is %d\\n",i);
}
发表于 2007-5-2 00:18:04 | 显示全部楼层
#include"stdio.h"
main()
{
  void strle(char *p);
  char array[10];
  gets(array);

  strle(array);
}
void strle(char *p)
{
  int i=0;
  char *p1;
  for(p1=p;*p1!='\\0';p1++)
    i++;
  printf("the answer is %d\\n",i);
}

楼上有部分写错了......
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|幻想森林

GMT+8, 2026-10-30 21:00 , Processed in 0.010200 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表