鱼C论坛

 找回密码
 立即注册
查看: 3166|回复: 1

大家帮我看一下,谢谢,真的不知怎么解决

[复制链接]
发表于 2015-12-28 22:37:02 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
#define _STDC_WANT_LIB_EXT1 1
#include <stdio.h>
#include<string.h>
#include<stddef.h>

#define TEXT_LEN 10000
#define BUF_SIZE 100
#define MAX_WORDS 500
#define WORD_LEN 12
#define ture 1
#define false 0

// strcat_s(char*strDestination,size_t numberOfElements,constchar *strSource) //申明strcat_s函数

int main()
{

char delimiters []="\n\".,;!?)(";
char text [TEXT_LEN]="";
char buf [BUF_SIZE];
char words[MAX_WORDS][WORD_LEN];
int nword[MAX_WORDS] ={0};
int word_count = 0;
int i=0;
//unsigned int   size_t;

printf("Enter text on an arbittrary number of lines.");
    printf("\nEnter an empty line to end inpupt:\n");

//Read an arbitarary numnber of lines of text

while (ture)
{
size_t len = TEXT_LEN;
char *ptr = NULL;
char *pWord = strtok_s(text,&len,delimiters,&ptr);
char        new_word = ture;
//An empty string contingjust a newline
fgets(buf,BUF_SIZE,stdin);
if(buf[0] == '\n')
{
break;
}
//Check if we have space for latest input
if(strcat_s(text,sizeof(text),buf))
{
printf("Maximum capactity fott text exceted ,Terminating program.\n");
return 1;
}

//Find the frist word
//        size_t len = TEXT_LEN;
//        size_t len = TEXT_LEN;
//        char *ptr = NULL;
//        char* pWord = strtok_s(text, &len, delimiters,&ptr);
if(!pWord)
{
printf("No words found.Ending program.\n");
return 1;
}
strncpy_s(words[word_count],WORD_LEN,pWord);
++nword [word_count++];


while (ture)
{
int i = 0;
pWord = strtok_s(NULL,&len,delimiters,&ptr);
if(!pWord)
{
break;
}
for(i = 0;i<word_count;++i)
{
++nword[i];
new_word = false;
}
}
if(new_word)
{
strncpy_s(words[word_count],WORD_LEN,pWord);
++nword[word_count++];
}
else
new_word = ture;

if(word_count>MAX_WORDS -1)
{
printf("CAPACITY TO STORE WORDS EXCEEDED.\n");
return 1;
}
}

for(i = 0;i<word_count;i++)
{
printf("%-13s %3d",words[i],nword[i]);
if((i+1)%4==0)
printf("\n");
}
printf("\n");
return 0;
}


想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-2-4 01:48:32 | 显示全部楼层
代码数大于20行是2请打注释哦
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-11-14 18:43

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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