我收到一個錯誤,指出我沒有太多的參數來調用'strcpy_s' 我已經查過它並找不到任何答案!感謝您的幫助提前。爲什麼我得到這個錯誤? strcpy
#include <stdio.h>
#include <string.h>
#define WORD_LENGTH 20
void read_line(char str[], int n);
int main(void)
{
char smallest_word[WORD_LENGTH];
char largest_word[WORD_LENGTH];
char current_word[WORD_LENGTH];
printf("Enter word: ");
read_line(current_word, WORD_LENGTH);
strcpy_s(smallest_word, strcpy_s(largest_word, current_word));
while (strlen(current_word) != 4);
{
printf("Enter word: ");
read_line(current_word, WORD_LENGTH);
if (strcmp(current_word, smallest_word) < 0)strcpy_s(smallest_word, 20, current_word);
if (strcmp(current_word, largest_word) > 0)strcpy_s(largest_word, 20, current_word);
}
printf("\nSmallest word: %s \n", smallest_word);
printf("Largest word: %s \n", largest_word);
return 0;
}
void real_line(char str[], int n)
{
int ch, i = 0;
while ((ch = getchar()) != '\n')
if (i < n)
str[i++] = ch;
str[i] = '\0';
}
爲'strcpy_s'簽名是'strcpy_s(字符*,爲size_t,爲const char *)',所以你需要包括'size_t'參數。 –
你查了一下,但你沒有閱讀手冊頁 - 你的第一個停靠港。 –
我真的不知道手冊頁是什麼。這是我第一個計算機科學課。我從來沒有聽說過它@韋瑟 – Crowe