cgets

cgets【cgets】函式名: cgets(在VC++6.0下为_cgets)
基本介绍中文名:cgets
功  能: 从键盘得到一个字元串
用  法: char *_cgets( char *buffer );
所属库:conio.h
相关函式::getch、getche、gets、getchar
函式简介函式名: cgets(在VC++6.0下为_cgets)功 能: 从键盘得到一个字元串用 法: char *_cgets( char *buffer );所属库:conio.h程式示例#include <conio.h>#include <stdio.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 %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;}下面的例子来自MSDN#include <conio.h>#include <stdio.h>#include <errno.h>int main( void ){char buffer[83] = { 80 }; // Maximum characters in 1st bytechar *result;printf( "Input line of text, followed by carriage return:\n");// Input a line of text:result = _cgets( buffer ); // C4996// Note: _cgets is deprecated; consider using _cgets_sif (!result){printf( "An error occurred reading from the console:"" error code %d\n", errno);}else{printf( "\nLine length = %d\nText = %s\n",buffer[1], result );}}