C/C++——С±à̸CÓïÑÔº¯ÊýÄÇЩÊÂ(11)
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. kbhitº¯Êý
kbhitº¯ÊýÊǼì²éµ±Ç°°´Ïµļü£¬ÆäÓ÷¨Îª£ºint kbhit(void);³ÌÐòÀý×ÓÈçÏ£º
#include <conio.h>
int main(void)
{
cprintf("Press any key to continue:");
while (!kbhit()) /* do nothing */ ;
cprintf("\r\nA key was pressed...\r\n");
return 0;
}
2. keepº¯Êý
keepº¯ÊýÊÇÍ˳ö²¢¼ÌÐøפÁô£¬ÆäÓ÷¨Îª£ºvoid keep(int status, int size);³ÌÐòÀý×ÓÈçÏ£º
#include <dos.h>
#define INTR 0x1C
#define ATTR 0x7900
extern unsigned _heaplen = 1024;
extern unsigned _stklen = 512;
void interrupt ( *oldhandler)(void);
void interrupt handler(void)
{
unsigned int (far *screen)[80];
static int count;
screen = MK_FP(0xB800,0);
count++;
count %= 10;
screen[0][79] = count + '0' + ATTR;
oldhandler();
}
int main(void)
{
oldhandler = getvect(INTR);
setvect(INTR, handler);
keep(0, (_SS + (_SP/16) - _psp));
return 0;
}
3. lfindº¯Êý
Lfindº¯ÊýÊÇÖ´ÐÐÏßÐÔËÑË÷£¬ÆäÓ÷¨Îª£ºvoid *lfind(void *key, void *base, int *nelem, int width, int (*fcmp)()); ³ÌÐòÀý×ÓÈçÏ£º
#include <stdio.h>
#include <stdlib.h>
int compare(int *x, int *y)
{
return( *x - *y );
}
int main(void)
{
int array[5] = {35, 87, 46, 99, 12};
size_t nelem = 5;
int key;
int *result;
key = 99;
result = lfind(&key, array, &nelem,
sizeof(int), (int(*)(const void *,const void *))compare);
if (result)
printf("Number %d found\n",key);
else
printf("Number %d not found\n",key);
return 0;
}
Ïà¹ØÎĵµ£º
ÔÚNotes µÄC/S ±à³ÌÖУ¬¾³£ÐèÒª¶ÔÒ»¸ö¼¯ºÏÖеĶÔÏó½øÐбéÀú´¦Àí£¬ÕâʱÈç¹ûÄÜÏÔʾһ¸ö½ø¶ÈÌõָʾµ±Ç°´¦Àí½ø³Ì£¬¾Í±È½ÏÖ±¹ÛÐÎÏ󣬿ͻ§½çÃæÒ²±È½ÏÓѺá£
1¡¢ÉùÃ÷APIº¯Êý
'ÉùÃ÷APIº¯Êý
Declare Function NEMProgressBegin Lib&nbs ......
ʱ³£ÔÚcppµÄ´úÂëÖ®Öп´µ½ÕâÑùµÄ´úÂë:
#ifdef __cplusplus
extern "C" {
#endif
//Ò»¶Î´úÂë
#ifdef __cplusplus
}
#endif
¡¡¡¡ÕâÑùµÄ´úÂëµ½µ×ÊÇʲôÒâ˼ÄØ£¿Ê×ÏÈ£¬__cplusplusÊÇcppÖеÄ×Ô¶¨Òåºê£¬ÄÇô¶¨ÒåÁËÕâ¸öºêµÄ»°±íʾÕâÊÇÒ ......
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. fcloseº¯Êý
fcloseº¯ÊýµÄ¹¦ÄÜÊǹرÕÒ»¸öÁ÷£¬ÆäÓ÷¨ÊÇ£ºint fclose(FILE *stream); ³ÌÐòÀý×ÓÈçÏ£º
#include <string.h& ......
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. gcvtº¯Êý
gcvtº¯ÊýµÄ¹¦ÄÜÊǰѸ¡µãÊýת»»³É×Ö·û´®£¬ÆäÓ÷¨ÊÇ£ºchar *gcvt(double value, int ndigit, char *buf);³ÌÐò ......
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. harderrº¯Êý
harderrº¯ÊýµÄ¹¦ÄÜÊǽ¨Á¢Ò»¸öÓ²¼þ´íÎó´¦Àí³ÌÐò£¬ÆäÓ÷¨ÊÇ£ºvoid harderr(int (*fptr)());³ÌÐòÀý×ÓÈçÏ£º
#include <stdio.h>
......