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
Ïà¹ØÎĵµ£º
ijЩ³¡ºÏ£¬ÈçÓÎÏ·¿ª·¢£¬¹¤³Ì¼ÆËãÖУ¬¿ÉÄÜÐèÒª¼ÆËã·´Èý½Çº¯Êý£¬ÏÂÃæÊǼÆËã·´ÕýÇÐÈý½Çº¯ÊýµÄcÔ´´úÂëʵÀý£º
atan_self(double x)
{
//atan(x)=x-x^3/3+x^5/5-x^7/7+.....(-1<x<1)
//return:[-pi/2,pi/2]
double mult,sum,xx;
sum=0;
if(x==1){
return pi/4;
}
if(x==-1){
return -pi/4;
}
((x&g ......
ÌâÄ¿£ºÊäÈëÈý¸ö×Ö·û´®a£¬bºÍc£¬½«aÖÐbµÄµÚÒ»´Î³öÏÖÌ滻Ϊc¡£
´úÂ룺
#include <iostream.h>
#include <string.h>
/*×Ö·û´®Ìæ»»£¬µÚÒ»¸ö²ÎÊýΪԴ®£¬µÚ¶þ¸ö²ÎÊýΪҪƥÅäµÄ×Ó´®
µÚÈý¸ö²ÎÊýΪҪÌæ»»µÄµÚÒ»¸ö×Ó´®Öаüº¬µÚ¶þ¸ö×Ó´®µÄ²¿·Ö*/
char *strReplace(char *str1,char *str2,char *str3);
void main() ......
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. settextstyleº¯Êý
settextstyleº¯ÊýµÄ¹¦ÄÜÊÇΪͼÐÎÊä³öÉèÖõ±Ç°µÄÎı¾ÊôÐÔ£¬ÆäÓ÷¨Îª£ºvoid far settextstyle (int font, int direction, char size);³ ......
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. setwritemodeº¯Êý
setwritemodeº¯ÊýµÄ¹¦ÄÜÊÇÉèÖÃͼÐη½Ê½Ï»ÏßµÄÊä³öģʽ£¬ÆäÓ÷¨Îª£ºvoid far setwritemode(int mode);³ÌÐòʵÀýÈçÏ£º
#include < ......