C/C++——С±à̸CÓïÑÔº¯ÊýÄÇЩÊÂ(26)
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. sopenº¯Êý
sopenº¯ÊýµÄ¹¦ÄÜÊÇ´ò¿ªÒ»¹²ÏíÎļþ£¬ÆäÓ÷¨Îª£ºint sopen(char *pathname, int access, int shflag, int permiss);³ÌÐòʵÀýÈçÏ£º
#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>
#include <process.h>
#include <share.h>
#include <stdio.h>
int main(void)
{
int handle;
int status;
handle = sopen("c:\\autoexec.bat", O_RDONLY, SH_DENYNO, S_IREAD);
if (!handle)
{
printf("sopen failed\n");
exit(1);
}
status = access("c:\\autoexec.bat", 6);
if (status == 0)
printf("read/write access allowed\n");
else
printf("read/write access not allowed\n");
close(handle);
return 0;
}
2. spawnlº¯Êý
spawnlº¯ÊýµÄ¹¦ÄÜÊÇ´´½¨²¢ÔËÐÐ×Ó³ÌÐò£¬ÆäÓ÷¨Îªint spawnl(int mode, char *pathname, char *arg0,arg1, ... argn, NULL);³ÌÐòʵÀý´úÂëÈçÏ£º
#include <process.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
int result;
clrscr();
result = spawnl(P_WAIT, "tcc.exe", NULL);
if (result == -1)
{
perror("Error from spawnl");
exit(1);
}
return 0;
}
3. srandº¯Êý
srandº¯ÊýµÄ¹¦ÄÜÊdzõʼ»¯Ëæ»úÊý·¢ÉúÆ÷, ÆäÓ÷¨Îª£ºvoid srand(unsigned seed);³ÌÐòʵÀý´úÂëÈçÏ£º
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(void)
{
int i;
time_t t;
srand((unsigned) time(&t));
printf("Ten random numbers from 0 to 99\n\n");
fo
Ïà¹ØÎĵµ£º
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. setallpalletteº¯Êý
setallpalletteº¯ÊýµÄ¹¦ÄÜÊÇ°´Ö¸¶¨·½Ê½¸Ä±äËùÓеĵ÷É«°åÑÕÉ«£¬ÆäÓ÷¨Îª£ºvoid far setallpallette(struct palette, fa ......
1.1= Óë ==
Àý1£º
±¾ÀýÖÐÑ»·Óï¾äµÄ±¾ÒâÊÇÌø¹ýÎļþÖеĿոñ·û¡¢ÖƱí·û¡¢»»Ðзû
while(c=''||c=='\t'||c=='\n')
c=getc(f);
c= ''||c=='\t'||c=='\n'
ËÀÑ»·
Àý2£º
if((filedesc==open(argv[i],0))<0)
error();
ÓÀÔ¶²»»á±»µ÷ÓÃ
1.2 & ºÍ | ²»Í¬ÓÚ&& ºÍ||
1.3 CÓ ......
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. setvectº¯Êý
setvectº¯ÊýµÄ¹¦ÄÜÊÇÉèÖÃÖжÏʸÁ¿Èë¿Ú£¬ÆäÓ÷¨Îª£ºvoid setvect(int intr_num, void interrupt(*isr)());³ÌÐòʵÀýÈçÏ£º
#include <st ......
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. setwritemodeº¯Êý
setwritemodeº¯ÊýµÄ¹¦ÄÜÊÇÉèÖÃͼÐη½Ê½Ï»ÏßµÄÊä³öģʽ£¬ÆäÓ÷¨Îª£ºvoid far setwritemode(int mode);³ÌÐòʵÀýÈçÏ£º
#include < ......