如何提示用户输入国家名称,例如Malaysia
将变量替换country1
为Malaysia
?
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
writeRecipe (int fd)
{
readData ();
char country1[LINE_MAX] = "China";
static char* line1 = "Starting Country Search Client ...\n\n\n";
static char* line2 = "**********************************************";
static char* line3 = "Welcome to the Country Info Directory Service!";
static char* line4 = "**********************************************\n\n";
write (fd, line1, strlen (line1) + 1); /* Write first line */
write (fd, line2, strlen (line2) + 1); /* Write second line */
write (fd, line3, strlen (line3) + 1); /* Write third line */
write (fd, line4, strlen (line4) + 1); /* Write fourth line */
puts("Please enter country > ");
fgets(country1, sizeof country1,stdin);
printf ("\n%s Capital : %s\n", country1, getCapital (country1));
printf ("%s Currency Code : %s\n", country1, getCurrencyCode (country1));
}