Ok here is the .txt which is actually a .dat file:
533 1100
#mapa portugal
inic_pol
150 842
103 1042
478 1036
442 845
fim_pol
inic_pol
15 380
150 842
407 843
401 608
81 376
fim_pol
inic_pol
81 376
364 583
328 56
95 45
fim_pol
I have to use g2 library to draw the polygons that im thinking of drawing line to line.
The code that ive written is now showing trouble compiling, in the console appears :
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
Never the less here it goes, the shock to any mediocre programer:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <g2.h>
#include <g2_PS.h>
#include <string.h>
int main(){
int x, y;
int x1, y1, x2, y2;
int i, id;
char linha[1024];
char inicio[9] = "inic_pol\n";
char fim[8] = "fim_pol\n";
i = 0;
FILE * fp;
fp = fopen("mapa1.dat" , "r");
if (fp == NULL){
printf ("ERRO: ficheiro inexistente\n");
return(0);
}
fgets(linha,[1024],fp);
sscanf(linha, "%d %d\n", &x, &y);
id = g2_open_X11( x , y);
if ((strncmp( linha, inicio ))== NULL){
while((strncmp( linha, fim ) != NULL){
sscanf(linha, "%d %d\n", &x1, &y1);
sscanf(linha, "%d %d\n", &x2, &y2);
g2_line(id, x1, y1, x2, y2);
}
fclose(fp);
}