函式名
cgets功能
函式語法
char *cgets(char *str);
程式演示
#include
#include
int main(void)
{
char buffer【83】;
char *p;
/* There's space for 80 characters plus the NULL terminator */
buffer【0】 = 81;
printf("Input some chars:");
p = cgets(buffer);
printf("\ncgets read %dcharacters: \"%s\"\n", buffer【1】, p);
printf("The returned pointer is %p, buffer【0】 is at %p\n", p, &buffer);
/* Leave room for 5 characters plus the NULL terminator */
buffer【0】 = 6;
printf("Input some chars:");
p = cgets(buffer);
printf("\ncgets read %d characters: \"%s\"\n", buffer【1】, p);
printf("The returned pointer is %p, buffer【0】 is at %p\n", p, &buffer);
return 0;
}