bianhengzhidao 发表于 2015-12-28 22:37:02

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

#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 ="";
char buf ;
char words;
int nword ={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 == '\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_LEN,pWord);
++nword ;


while (ture)
{
int i = 0;
pWord = strtok_s(NULL,&len,delimiters,&ptr);
if(!pWord)
{
break;
}
for(i = 0;i<word_count;++i)
{
++nword;
new_word = false;
}
}
if(new_word)
{
strncpy_s(words,WORD_LEN,pWord);
++nword;
}
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,nword);
if((i+1)%4==0)
printf("\n");
}
printf("\n");
return 0;
}


xxm8023 发表于 2021-2-4 01:48:32

代码数大于20行是2请打注释哦
页: [1]
查看完整版本: 大家帮我看一下,谢谢,真的不知怎么解决