| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 886 人关注过本帖
标题:请大家看看为什么无法输出字符数
只看楼主 加入收藏
Lxy111
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2018-3-5
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
请大家看看为什么无法输出字符数
#include<stdio.h>
#define LENGTH 80
int put2(const*string);
int main(void)
{
    char ary[LENGTH];
    printf("Enter sth:");
    fgets(ary, LENGTH, stdin);
    printf("%d Words.\n", put2(ary));
    system("pause");
    return 0;
}
int put2(const char*string)
{
    int count=0;
    while (*string)
    putchar(*string++);
    count++;
    putchar("\n");
    printf("%d Words\n", count);
    if (count = 0)
        return NULL;
    else
        return count;
}
搜索更多相关主题的帖子: 输出 int string return count 
2018-03-05 20:37
Lxy111
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2018-3-5
收藏
得分:0 
运行结果字符数总是?
2018-03-05 20:38
吹水佬
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:451
帖 子:10537
专家分:42927
注 册:2014-5-20
收藏
得分:10 
#include<stdio.h>
#define LENGTH 80
//int put2(const*string);
int put2(const char *string);
int main(void)
{
    char ary[LENGTH];
    printf("Enter sth:");
    fgets(ary, LENGTH, stdin);
    printf("%d Words.\n", put2(ary));
    system("pause");
    return 0;
}
int put2(const char *string)
{
    int count=0;
    while (*string && *string!='\n')
    {
        putchar(*string++);
        count++;
    }
    putchar('\n');
    printf("%d Words\n", count);
    return count;
}
2018-03-05 21:24
新人学习
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:145
专家分:187
注 册:2017-10-26
收藏
得分:10 
#include<stdio.h>
#include<stdlib.h>
#define LENGTH 80
int put2(const char *string);
int main(void)
{
    char ary[LENGTH];
    printf("Enter sth:");
    fgets(ary, LENGTH, stdin);
    printf("%d Words.\n", put2(ary));
    system("pause");
    return 0;
}
int put2(const char*string)
{
    int count=0;
    while (*string)
    {
        putchar(*string++);
        count++;
    }
    putchar('\n');
    printf("%d Words\n", count);
    if (count = 0)
        return NULL;
    else
        return count;
}
2018-03-05 21:45
快速回复:请大家看看为什么无法输出字符数
数据加载中...
 
   



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

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