C语言函数—chdir

函数名

cgets

功 能

从控制台读字符串

用 法

char *cgets(char *str);

程序例

#include <stdio.h> 
#include <conio.h> 

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 %d characters: "%s"n", buffer[1], p); 
   printf("The returned pointer is %p, buffer[0] is at %pn", 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 %pn", p, &buffer); 
   return 0; 
} 
  
  
  

如果引用本站的原创文章,请注明原文链接:,本站保留追究责任的权利!