用C讀取DXF中的直線數量和座標

2021-06-22 19:43:18 字數 1717 閱讀 4775

首先,定義直線、圓的結構體,把它們儲存在inestruct.h中

//#include "linestruct.h" 

#define strlen           60

#define datasize sizeof(entitydata)

/*-----每個實體的結構-----*/

//你可在在此新增其它的實體

//為了提高精度,變數可定義為雙精度型

typedef struct taglineline;

typedef struct tagcirclecircle;

/*------------------------*/

typedef union specialdataprivatedata;

/*------實體的資料結構-------*/

typedef struct commondataentitydata;

//定義完資料結構後,就可以用鍊錶結構來儲存實體中有用的資訊了。

//以下程式為讀取實體line的有關資訊的**。

/*------------------------------------------

*entity.c 讀取實體line部分內容。

*-------------------------------------------*/

然後,在line.cpp中實現讀取直線的數量、直線兩端端點的座標

#include "linestruct.h" 

#include #include #include #include /*----------函式宣告部分-----------*/

void print(entitydata *entity);

/*---------------------------------*/

int main(int argc,char *argv)

else

entity = entity2 = (entitydata *)malloc(datasize);

while(!feof(dxf)) }}

entity2->next = entity1;

entity2 = entity1;}}

entity2->next = null;}}

entity = entity->next; //第乙個實體區為空,所以使頭指標移向下乙個實體

print(entity); //輸出鍊錶

printf("\npress any key to halt...");

getch();

return 0;}

//輸出鍊錶

void print(entitydata *entity)

while(pointer != null);

}printf("\noutput linklist:");

printf("\ndxf檔案中總共有%d條直線:\n",i);

i = 1;

pointer = entity;

if(pointer != null) while(pointer !=null);}}

效果如下:

用c 實現檔案的讀取和系列操作

1.解題思路 首先要先讀取檔案,然後呼叫函式實現返回檔案的字元數,行數,單詞總數。用的是c 來做。主要實現的功能 wc.exe c mrhu.txt 返回檔案 mrhu.txt 的字元數 wc.exe w mrhu.txt 返回檔案 mrhu.txt 的單詞總數 wc.exe l mrhu.txt ...

c和c 中讀取資料的方式總結

最近在學習c和c 除了在寫os的時候用到外,寫演算法的時候也會用到,整理記錄c和c 讀取資料的各種方式。輸入c 輸出文章較長,總結稍微詳細了一點。在stdio.h中包含最經典的輸出函式printf include 執行 printf 函式需要該庫 intmain 格式化輸出,在printf中格式化輸...

c和c 中讀取資料的方式總結

最近在學習c和c 除了在寫os的時候用到外,寫演算法的時候也會用到,整理記錄c和c 讀取資料的各種方式。目錄輸入 c 輸出 文章較長,總結稍微詳細了一點。在stdio.h中包含最經典的輸出函式printf include 執行 printf 函式需要該庫 int main 格式化輸出,在printf...