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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

C语言设计新思维分享

發布時間:2025/3/15 编程问答 15 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C语言设计新思维分享 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

沒有任何套路,直接獲取資源
C語言已經有幾十年的歷史了,經過長時間的發展和普及,C語言的應用場景也有了很大的變化,一些的老的觀念已經不在適用,在這里給大家推薦一本講C語言特別好的書,《C語言設計新思維》,沒有任何套路直接下發領取。

書中展現了傳統C語言教科書所不具備的最新的相關技術,如果你有一定的C語言基礎并且迫切的想提高自己的C語言編程能力,那么推薦你看下。

C語言設計新思維

根據調用生成不同的函數

#define def_object_copy(tname, ...) \void * tname##_copy(tname *in) { \tname *out = malloc(sizeof(tname)); \*out = *in; \__VA_ARGS__; \return out; \} def_object_copy(keyval) // Expands to the previous declarations of keyval_copy. #include <stdio.h> #include <math.h> typedef struct point {double x, y; } point; typedef struct {//匿名結構體,定義之后相當于將原有的結構體成員直接放到這個地方struct point; ?double z; } threepoint; double threelength (threepoint p){return sqrt(p.x*p.x + p.y*p.y + p.z*p.z); ? } int main(){threepoint p = {.x=3, .y=0, .z=4}; ?printf("p is %g units from the origin\n", threelength(p)); }

匿名聯合體與匿名結構體的集合

/* Compile with: make LDLIBS='-lm' CFLAGS="-g -Wall -std=gnu11 -fms-extensions" seamlesstwo */ #include <stdio.h> #include <math.h>typedef struct point {double x, y; } point;typedef struct {union {struct point;point p2;};double z; } threepoint;double length (point p){return sqrt(p.x*p.x + p.y*p.y); }double threelength (threepoint p){return sqrt(p.x*p.x + p.y*p.y + p.z*p.z); }int main(){threepoint p = {.x=3, .y=0, .z=4};printf("p is %g units from the origin\n", threelength(p));double xylength = length(p.p2);printf("Its projection onto the XY plane is %g units from the origin\n", xylength); }

如果不使用-fms-extensions標志,那么就是弱模式了。它不允許我
們使用匿名的結構標識符來引用我們以前定義過的結構,相反,它要求
結構必須在本地定義。這樣,我們需要復制和粘貼整個P2 struct的定義
了。

typedef struct { union {struct {double x, y;};point p2;};double z; } threepoint;

總結

以上是生活随笔為你收集整理的C语言设计新思维分享的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。