C Primer Plus (第6版)中文版 P294中程序清单11.18 str_cat.c程序,运行错误,strcat_s用于调用的参数太少,麻烦各位,怎么修改才不会有错误
#include <stdio.h>
#include <string.h>
#define SIZE 80
char* s_gets(char* st, int n);
int main(void)
{
char flower[SIZE];
char addon[] = "s smell like old shoes.";
puts("What is your favorite flower?");
if (s_gets(flower, SIZE))
{
strcat_s(flower, addon);
puts(flower);
puts(addon);
}
else
puts("End of file encountered!");
puts("bye");
return 0;
}
char* s_gets(char* st, int n)
{
char* ret_val;
int i = 0;
ret_val = fgets(st, n, stdin);
if (ret_val)
{
while (st[i] != '\n' && st[i] != '\0')
i++;
if (st[i] == '\n')
st[i] = '\0';
else
while (getchar() != '\n')
continue;
}
return ret_val;
}