日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

看框架总结

發(fā)布時(shí)間:2025/3/21 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 看框架总结 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1、使用函數(shù)sprintf過程中產(chǎn)生的錯(cuò)誤:

#include<stdio.h>
#include<string.h>
int main()
{
??? char *string = "a good student";
??? char?*str;

??? sprintf(str,"%s",string);
??? printf("%s\n",str);

??? return 0;??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
}

結(jié)果報(bào)錯(cuò):no stack,原因沒有對str申請空間,解決方案:

?

#include<stdio.h>
#include<string.h>
int main()
{
??? char *string = "a good student";
??? char str[256];
??? sprintf(str,"%s",string);
??? printf("%s\n",str);

??? return 0;??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
}

運(yùn)行結(jié)果:a good student

?

2、ANSI C預(yù)定義的宏__TIME__:獲取編譯時(shí)時(shí)間

程序:

#include<stdio.h>
int main()
{
???? printf("%s",__TIME__);?????????????????????????????????????????????????????????????????????????????????????????????????????????

}

結(jié)果:

15:30:47

?

拓展:

__LINE__:在源代碼中插入當(dāng)前源代碼行號;

__FILE__:在源文件中插入當(dāng)前源文件名;

__DATE__:在源文件中插入當(dāng)前的編譯日期

__TIME__:在源文件中插入當(dāng)前編譯時(shí)間;

__STDC__:當(dāng)要求程序嚴(yán)格遵循ANSI C標(biāo)準(zhǔn)時(shí)該標(biāo)識被賦值為1;

?

?

3、文件操作符lseek()

off_t lseek(int fd, off_t offset, int whence);

返回的是fd到whence之間的偏移量,如果fd一開始被定義為0,whence被定義為SEEK_END,則返回的是文件的長度。

?

4、學(xué)習(xí)使用ifdef...else...endif

int main()
{
??? #ifdef mood
??????? printf("nice\n");
??? #else
??????? printf("woe");
??? #endif
----
??? #ifdef feagure
??????? printf("beautiful");
??? #endif
??? return 0;
}

//result:
woe

?

5、get_current_dir_name()獲取當(dāng)前目錄

#include<stdio.h>
#include<unistd.h>
#include<string.h>
#define _GNU_SOURCE

int main()
{
??? char **str = (char *)strdup(get_current_dir_name());
??? printf("filename:%s\n",str);
}

//result:
//filename:/home/jeanyu/mywork

?

6、學(xué)習(xí)左移符號<<的使用

#include<stdio.h>
#include<stdint.h>
int main()
{
????? int8_t a;
????? a = 1<<7;
????? printf("%u\n",1<<8);
????? printf("%d\n",a);
????? return 0;
}
//result
//256

?

7、求換行符、tab符等的ACSII值

#include<stdio.h>
int main()
{
>---printf("%d,%d,%d,%d,%d\n",' ','\r','\t','\n','=');
}
//result
//32,13,9,10,61

《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的看框架总结的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。