C ÓïÑÔÖÐÇå¿ÕÊäÈ뻺³åÇø
CÓïÑÔÖÐÓм¸¸ö»ù±¾ÊäÈ뺯Êý£º
//»ñÈ¡×Ö·ûϵÁÐ
int fgetc(FILE *stream);
int getc(FILE *stream);
int getchar(void);
//»ñÈ¡ÐÐϵÁÐ
char *fgets(char * restrict s, int n, FILE * restrict stream);
char *gets(char *s);//¿ÉÄܵ¼ÖÂÒç³ö£¬ÓÃfgets´úÌæÖ®¡£
//¸ñʽ»¯ÊäÈëϵÁÐ
int fscanf(FILE * restrict stream, const char * restrict format, …);
int scanf(const char * restrict format, …);
int sscanf(const char * restrict str, const char * restrict format, …);
ÕâÀï½öÌÖÂÛÊäÈ뺯ÊýÔÚ±ê×¼ÊäÈ루stdin£©Çé¿öϵÄʹÓá£×ݹÛÉÏÊö¸÷ÊäÈ뺯Êý£¬»ñÈ¡×Ö·ûϵÁеĵÄǰÈý¸öº¯Êýfgetc¡¢getc¡¢getchar¡£ÒÔgetcharΪÀý£¬½«ÔÚstdin»º³åÇøÎª¿Õʱ£¬µÈ´ýÊäÈ룬ֱµ½»Ø³µ»»ÐÐʱº¯Êý·µ»Ø¡£Èôstdin»º³åÇø²»Îª¿Õ£¬getcharÖ±½Ó·µ»Ø¡£getchar·µ»ØÊ±´Ó»º³åÇøÖÐÈ¡³öÒ»¸ö×Ö·û£¬²¢½«Æäת»»Îªint£¬·µ»Ø´ËintÖµ¡£
MINGW 4.4.3ÖÐFILE½á¹¹ÌåÔ´Â룺
typedef struct _iobuf
{
char* _ptr;//Ö¸Ïòµ±Ç°»º³åÇø¶ÁȡλÖÃ
int _cnt;//»º³åÇøÖÐÊ£ÓàÊý¾Ý³¤¶È
char* _base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char* _tmpfname;
} FILE;
¸÷±àÒëÆ÷ʵÏÖ¿ÉÄܲ»Ò»Ñù£¬ÕâÀï»ñÈ¡×Ö·ûϵÁк¯ÊýÖ»Óõ½_ptrºÍ_cnt¡£MINGW 4.4.3ÖÐgetchar()ʵÏÖ£º
__CRT_INLINE int __cdecl __MINGW_NOTHROW getchar (void)
{
return (--stdin->_cnt >= 0)
? (int) (unsigned char) *stdin->_ptr++
: _filbuf (stdin);
}
ÆäÖÐstdinΪFILEÖ¸ÕëÀàÐÍ£¬ÔÚMINGW 4.4.3ÖУ¬getc()ºÍgetchar()ʵÏÖΪÄÚÁªº¯Êý£¬fgetc()ʵÏÖΪº¯Êý¡£Ë³±ã˵һ¾ä£¬C99±ê×¼ÖÐÒѾ¼ÓÈë¶ÔÄÚÁªº¯ÊýµÄÖ§³ÖÁË¡£
»ñÈ¡ÐÐϵÁеÄfgetsºÍgets£¬ÆäÖÐÓÉÓÚgetsÎÞ·¨È·¶¨»º³åÇø´óС£¬³£µ¼ÖÂÒç³öÇé¿ö£¬ÕâÀï²»ÍÆ¼öÒ²²»ÌÖÂÛgetsº¯Êý¡£¶ÔÓÚfgetsº¯Êý£¬Ã¿´ÎÇÃÈë»Ø³µ£¬fgets¼´·µ»Ø¡£fgets³É¹¦·µ»ØÊ±£¬½«ÊäÈ뻺³åÇøÖеÄÊý¾ÝÁ¬»»Ðзû’ ’Ò»Æð¿½±´µ½µÚÒ»¸ö²ÎÊýËùÖ¸ÏòµÄ¿Õ¼äÖС£ÈôÊäÈëÊý¾Ý³¬¹ý»º³åÇø³¤¶È£¬fgets»á½ØÈ¡Êý¾Ýµ½Ç°n-1£¨nΪfgetsµÚ¶þ¸ö²ÎÊý£¬ÎªµÚÒ»¸ö²ÎÊýÖ¸Ïò¿Õ¼äµÄ³¤¶È£©£¬È»ºóÔÚĩβ¼ÓÈë’ ’¡£Òò´ËfgetsÊǰ²È«µÄ¡£Í¨³£ÓÃfgets(buf, BUF_LEN, stdin);´úÌægets(buf);¡£
¸ñʽ»¯ÊäÈëϵ
Ïà¹ØÎĵµ£º
¹Ø¼üµÄʱ¿Ì - MFC Or Not
ÔÚSymantec C/C++ºÍWatcom C/C++Öð½¥µØÕ¾ÎÈÁ˽Ų½Ö®ºó£¬ËÄ´ó±àÒëÆ÷¾öÕ½µÄʱ¿ÌÒ²Ö𽥱ƽüÁË¡£ÔÚ1994ÄêδµÄ¾öս֮ǰ£¬SymantecºÍWatcomÍ¬Ê±Ãæ¶ÔÁËÒ»¸ö·Ç³£ÑÏÀ÷µÄ¿¼Ñ飬ÄǾÍÊÇC/C++ FrameworkµÄÑ¡Ôñ¡£ËäÈ»SymantecºÍWatcom¶¼ÒÔ¸÷×ÔµÄÌØÉ«Õ¼µÃÁËÊг¡£¬²»¹ýÔÚµ±Ê±¶ÔÓÚÒ»¸öC/C++¿ª·¢¹¤¾ßÀ´Ëµ£¬×îÖØÒªµÄÒ ......
#include <assert.h>¡¡¡¡¡¡¡¡//É趨²åÈëµã
#include <ctype.h>¡¡¡¡¡¡¡¡ //×Ö·û´¦Àí
#include <errno.h>¡¡¡¡¡¡¡¡ //¶¨Òå´íÎóÂë
#include <float.h>¡¡¡¡¡¡¡¡ //¸¡µãÊý´¦Àí
#include <fstream.h>¡¡¡¡¡¡ //ÎļþÊäÈ룯Êä³ö
#include  ......
#include<stdio.h>
#include<malloc.h>
#include<string.h>
/*
* ·×ª
*/
char *mystrrev(char *arr)
{
if (!arr)
{
return NULL;
}
char *temp = arr;
char t;
int leng = strlen(arr) + 1;
int l = (int)(leng / 2);
int i = 0;
while (l--)
{
t = arr[i];
arr[ ......
#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 100
main()
{
FILE *fp;
if ( (fp = fopen( "c:\\a.txt", "r" )) == NULL ) printf("ERROR!\n");
int tmp[MAXSIZE];
int i;
for ( i=0; i<MAXSIZE; i++ )
{
tmp[i] = 0; ......
Õ⼸ÌìÎÒ°²×°ÁËÒ»¸öLinuxϵͳ£¬ÏëÔÚÀïÃæÑ§Ò»ÏÂCÓïÑԵıàд£¬·¢ÏÖÔÚÀïÃæÔËÐÐÓÐÒ»¸öºÃÆæ¹ÖµÄÏÖÏó£ºÈçÏÂÃæ
#include<stdio.h>
void mian(){
printf("hello world!");
}
Êä³öûÓнá¹û£¡¸ãµÄÎÒ¿´Á˰ëÌ죬³ÌÐòûÓдíÎó°¡£¡ÔõôÕâÑù£¡ºóÀ´ÎҰѳÌÐò¸ÄΪ
#include<stdio.h>
void mian(){
printf("hello ......