#include "pch.h"
#include <iostream>
#include <string.h>
#define SIZE 80
char *s_gets(char*st, int n);
int main()
{
std::cout << "Hello World!\n";
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);
return 0;
getchar();
}
}
char *s_gets(char*st, int n)
{
char *hua;
int i = 0;
hua = fgets(st, n, stdin);
if (hua)
{
while (st[i] != '\n'&&st[i] != '\0')
i++;
if (st[i]=='\n')
{
st[i] = '\0';
}
else
{
while (getchar()!='\n')
{
continue;
}
}
}
return hua;
}
效果图