新聞中心
求C語言函數(shù)大全
函數(shù)名: abort
創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都做網(wǎng)站、網(wǎng)站制作、臨湘網(wǎng)絡(luò)推廣、微信小程序開發(fā)、臨湘網(wǎng)絡(luò)營銷、臨湘企業(yè)策劃、臨湘品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供臨湘建站搭建服務(wù),24小時服務(wù)熱線:18982081108,官方網(wǎng)址:www.cdcxhl.com
功 能: 異常終止一個進(jìn)程
用 法: void abort(void);
程序例:
#include stdio.h
#include stdlib.h
int main(void)
{
printf("Calling abort()\n");
abort();
return 0; /* This is never reached */
}
函數(shù)名: abs
功 能: 求整數(shù)的絕對值
用 法: int abs(int i);
程序例:
#include stdio.h
#include math.h
int main(void)
{
int number = -1234;
printf("number: %d absolute value: %d\n", number, abs(number));
return 0;
}
函數(shù)名: absread, abswirte
功 能: 絕對磁盤扇區(qū)讀、寫數(shù)據(jù)
用 法: int absread(int drive, int nsects, int sectno, void *buffer);
int abswrite(int drive, int nsects, in tsectno, void *buffer);
程序例:
/* absread example */
#include stdio.h
#include conio.h
#include process.h
#include dos.h
int main(void)
{
int i, strt, ch_out, sector;
char buf[512];
printf("Insert a diskette into drive A and press any key\n");
getch();
sector = 0;
if (absread(0, 1, sector, buf) != 0)
{
perror("Disk problem");
exit(1);
}
printf("Read OK\n");
strt = 3;
for (i=0; i80; i++)
{
ch_out = buf[strt+i];
putchar(ch_out);
}
printf("\n");
return(0);
}
函數(shù)名: access
功 能: 確定文件的訪問權(quán)限
用 法: int access(const char *filename, int amode);
程序例:
#include stdio.h
#include io.h
int file_exists(char *filename);
int main(void)
{
printf("Does NOTEXIST.FIL exist: %s\n",
file_exists("NOTEXISTS.FIL") ? "YES" : "NO");
return 0;
}
int file_exists(char *filename)
{
return (access(filename, 0) == 0);
}
函數(shù)名: acos
功 能: 反余弦函數(shù)
用 法: double acos(double x);
程序例:
#include stdio.h
#include math.h
int main(void)
{
double result;
double x = 0.5;
result = acos(x);
printf("The arc cosine of %lf is %lf\n", x, result);
return 0;
}
函數(shù)名: allocmem
功 能: 分配DOS存儲段
用 法: int allocmem(unsigned size, unsigned *seg);
程序例:
#include dos.h
#include alloc.h
#include stdio.h
int main(void)
{
unsigned int size, segp;
int stat;
size = 64; /* (64 x 16) = 1024 bytes */
stat = allocmem(size, segp);
if (stat == -1)
printf("Allocated memory at segment: %x\n", segp);
else
printf("Failed: maximum number of paragraphs available is %u\n",
stat);
return 0;
}
函數(shù)名: arc
功 能: 畫一弧線
用 法: void far arc(int x, int y, int stangle, int endangle, int radius);
程序例:
#include graphics.h
#include stdlib.h
#include stdio.h
#include conio.h
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int stangle = 45, endangle = 135;
int radius = 100;
/* initialize graphics and local variables */
initgraph(gdriver, gmode, "");
/* read result of initialization */
errorcode = graphresult(); /* an error occurred */
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor());
/* draw arc */
arc(midx, midy, stangle, endangle, radius);
/* clean up */
getch();
closegraph();
return 0;
}
函數(shù)名: asctime
功 能: 轉(zhuǎn)換日期和時間為ASCII碼
用 法: char *asctime(const struct tm *tblock);
程序例:
#include stdio.h
#include string.h
#include time.h
int main(void)
{
struct tm t;
char str[80];
/* sample loading of tm structure */
t.tm_sec = 1; /* Seconds */
t.tm_min = 30; /* Minutes */
t.tm_hour = 9; /* Hour */
t.tm_mday = 22; /* Day of the Month */
t.tm_mon = 11; /* Month */
t.tm_year = 56; /* Year - does not include century */
t.tm_wday = 4; /* Day of the week */
t.tm_yday = 0; /* Does not show in asctime */
t.tm_isdst = 0; /* Is Daylight SavTime; does not show in asctime */
/* converts structure to null terminated
string */
strcpy(str, asctime(t));
printf("%s\n", str);
return 0;
}
函數(shù)名: asin
功 能: 反正弦函數(shù)
用 法: double asin(double x);
程序例:
#include stdio.h
#include math.h
int main(void)
{
double result;
double x = 0.5;
result = asin(x);
printf("The arc sin of %lf is %lf\n", x, result);
return(0);
}
函數(shù)名: assert
功 能: 測試一個條件并可能使程序終止
用 法: void assert(int test);
程序例:
#include assert.h
#include stdio.h
#include stdlib.h
struct ITEM {
int key;
int value;
};
/* add item to list, make sure list is not null */
void additem(struct ITEM *itemptr) {
assert(itemptr != NULL);
/* add item to list */
}
int main(void)
{
additem(NULL);
return 0;
}
函數(shù)名: atan
功 能: 反正切函數(shù)
用 法: double atan(double x);
程序例:
#include stdio.h
#include math.h
int main(void)
{
double result;
double x = 0.5;
result = atan(x);
printf("The arc tangent of %lf is %lf\n", x, result);
return(0);
}
函數(shù)名: atan2
功 能: 計算Y/X的反正切值
用 法: double atan2(double y, double x);
程序例:
#include stdio.h
#include math.h
int main(void)
{
double result;
double x = 90.0, y = 45.0;
result = atan2(y, x);
printf("The arc tangent ratio of %lf is %lf\n", (y / x), result);
return 0;
}
函數(shù)名: atexit
功 能: 注冊終止函數(shù)
用 法: int atexit(atexit_t func);
程序例:
#include stdio.h
#include stdlib.h
void exit_fn1(void)
{
printf("Exit function #1 called\n");
}
void exit_fn2(void)
{
printf("Exit function #2 called\n");
}
int main(void)
{
/* post exit function #1 */
atexit(exit_fn1);
/* post exit function #2 */
atexit(exit_fn2);
return 0;
}
函數(shù)名: atof
功 能: 把字符串轉(zhuǎn)換成浮點(diǎn)數(shù)
用 法: double atof(const char *nptr);
程序例:
#include stdlib.h
#include stdio.h
int main(void)
{
float f;
char *str = "12345.67";
f = atof(str);
printf("string = %s float = %f\n", str, f);
return 0;
}
函數(shù)名: atoi
功 能: 把字符串轉(zhuǎn)換成長整型數(shù)
用 法: int atoi(const char *nptr);
程序例:
#include stdlib.h
#include stdio.h
int main(void)
{
int n;
char *str = "12345.67";
n = atoi(str);
printf("string = %s integer = %d\n", str, n);
return 0;
}
函數(shù)名: atol
功 能: 把字符串轉(zhuǎn)換成長整型數(shù)
用 法: long atol(const char *nptr);
程序例:
#include stdlib.h
#include stdio.h
int main(void)
{
long l;
char *str = "98765432";
l = atol(lstr);
printf("string = %s integer = %ld\n", str, l);
return(0);
}
C語言的system()函數(shù)疑問!!瘋了!!
樓主用的什么編譯器?在本人機(jī)子上運(yùn)行正常,我用的是vs
Windows IP Configuration
Successfully flushed the DNS Resolver Cache.
Pinging [119.75.213.61] with 32 bytes of data:
Reply from 119.75.213.61: bytes=32 time=38ms TTL=53
Reply from 119.75.213.61: bytes=32 time=38ms TTL=53
Reply from 119.75.213.61: bytes=32 time=38ms TTL=53
Reply from 119.75.213.61: bytes=32 time=38ms TTL=53
Ping statistics for 119.75.213.61:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 38ms, Maximum = 38ms, Average = 38ms
樓主在return前加個getch()看看
終于知道樓主的問題了,樓主你的exe的文件名有問題,改成1.exe就行了。ping是一個命令哦?
對于這個疑問我查了一下資料,如下
ping.exe的原理
ping.exe的原理是,向指定的IP地址發(fā)送一定長度的數(shù)據(jù)包,按照約定,若指定IP地址存在的話,會返回同樣大小的數(shù)據(jù)包,當(dāng)然,若在特定的時間內(nèi)沒有返回,就是“超時”,就認(rèn)為指定的IP地址不存在。由于ping使用的是icmp協(xié)議,有些防火墻軟件會屏蔽掉icmp協(xié)議,所以有時候ping的結(jié)果只能做為參考,ping不通并不能就一定說明對方IP不存在。
Ping命令是一個非常有用的網(wǎng)絡(luò)命令,大家常用它來測試網(wǎng)絡(luò)連通情況。但同時它也是把“雙刃劍”,別人使用ping命令能探測到你計算機(jī)上的很多敏感信息,造成不安全。為了安全,防止ping的方法也有很多,比如防火墻,又比如創(chuàng)建一個禁止所有計算機(jī)Ping本機(jī)IP地址的安全策略。
C語言為什么總是看不懂?尤其是里面的英文函數(shù)名
一般老手寫的代碼 英文函數(shù)名都是根據(jù)英語單詞或者漢語拼音來的 這樣寫出來的代碼大家都好理解
c語言中函數(shù)名是否可以和變量同名?
答案是:否
c語言中,變量和函數(shù)名稱不允許相同,比如你定義一個函數(shù)int a();那么你的main函數(shù)中,如果int a=a();則會報錯,這是c語言中非常討厭的一點(diǎn),當(dāng)然,反對者可能會說:“容易引起名稱混淆,導(dǎo)致不容易維護(hù)”,這是很牽強(qiáng)的說法,用現(xiàn)在流行的詞匯叫做:強(qiáng)行為c語言的缺點(diǎn)洗白,c語言的這個限制,極大程度的增加了初學(xué)者,尤其是自學(xué)者的學(xué)習(xí)難度,因?yàn)槌鯇W(xué)者不會考慮變量的含義,通常定義aa,bb,cc這樣更利于快速學(xué)習(xí),但是出來這個限制,并且不知情的情況下,甚至都不知道在網(wǎng)上如何搜索來解決這個小問題,所以個人覺得這是c的不友好之一
編程中常見的Foo,是什么意思
簡單來說,foo就是習(xí)慣性用來做示例的類名或者函數(shù)方法名,指代一個沒有特定意義的實(shí)體。
就像我們想拿人舉例子,總要先起個名字,然后就喜歡用什么:張三,李四之類的。
真說意義呢?一般foo就是亂七八糟的意思,你隨便寫一個不成熟的或者不在框架內(nèi)的小類,方法,函數(shù)等,就可以用這個名,你也可以用abc這些詞代替,但是大家習(xí)慣這樣,你最好也這樣,大家都好理解。
反之,如果你要寫一個有特定意義或者功能的類,方法,函數(shù)時,使用的名稱最好跟他實(shí)現(xiàn)的功能有關(guān)聯(lián),這樣程序比較易讀。
C語言常用詞匯及函數(shù)有那些?
常用詞匯:
1、short:修飾int,短整型數(shù)據(jù),可省略被修飾的int。
2、long:修飾int,長整型數(shù)據(jù),可省略被修飾的int。
3、long long:修飾int,超長整型數(shù)據(jù),可省略被修飾的int。
4、signed:修飾整型數(shù)據(jù),有符號數(shù)據(jù)類型。
5、unsigned:修飾整型數(shù)據(jù),無符號數(shù)據(jù)類型。
6、restrict:用于限定和約束指針,并表明指針是訪問一個數(shù)據(jù)對象的唯一且初始的方式。
7、return:用在函數(shù)體中,返回特定值(如果是void類型,則不返回函數(shù)值)。
8、continue:結(jié)束當(dāng)前循環(huán),開始下一輪循環(huán)。
9、break:跳出當(dāng)前循環(huán)或switch結(jié)構(gòu)。
10、goto:無條件跳轉(zhuǎn)語句。
11、if:條件語句,后面不需要放分號。
12、else:條件語句否定分支(與if連用)。
13、switch:開關(guān)語句(多重分支語句)。
14、case:開關(guān)語句中的分支標(biāo)記,與switch連用。
15、default:開關(guān)語句中的“其他”分支,可選。
常用函數(shù):
1、int isalpha(int ch) 若ch是字母('A'-'Z','a'-'z'),返回非0值,否則返回0。
2、int isalnum(int ch) 若ch是字母('A'-'Z','a'-'z')或數(shù)字('0'-'9'),返回非0值,否則返回0。
3、int abs(int i) 返回整型參數(shù)i的絕對值。
4、double cabs(struct complex znum) 返回復(fù)數(shù)znum的絕對值。
5、double fabs(double x) 返回雙精度參數(shù)x的絕對值。
6、long labs(long n) 返回長整型參數(shù)n的絕對值。
參考資料來源:百度百科—C語言
本文名稱:c語言討厭的函數(shù)名 c語言中常用的函數(shù)
標(biāo)題URL:http://www.dlmjj.cn/article/dodpgps.html