Here is the code I have so far, thanks in advance.
Code:
#include "area.h"
/* this function reads the X- and Y-coordinates of points from a file
* creates a doubly linked circular list of the points
* returns a pointer to the list
*/
node *readPolygon(char filename[])
{
node *polygon;
/* use fopen() to open the file
* make sure the file is opened -- i.e. fopen() is successful
* exit() the program if not successful
* initialize an empty linked list
*
* loop
* use fgets() to read one line from the file
* use sscanf() to get the X- and Y-coordinates of a point
* use insertTail() to insert the point to the tail of the list
*
* don't forget to close the file by fclose()
*/
FILE *filepointer;
char record [1000];
node *linkedlist;
double x, y;
int first = 0;
filepointer = fopen(filename, "r");
if (filepointer == NULL){
printf("Error opening file\n");
exit(-1);
}
fgets (record, filepointer);
while (char !=NULL){
sscanf(filepointer, "%lf, %lf," &x, &y);
polygon = insertTail(polygon, x,y);
/* if (first ==0){
initList(node);
}
else {
insertTail(list, x, y);
}
fgets (record, filepointer);*/
}
fclose(filepointer);
return polygon;
}
}
Code:
icc -ansi -Wall -c -o readPolygon.o readPolygon.c
Error that im getting mostly in my fgets function
readPolygon.c(53): warning #810: conversion from "FILE *" to "int" may lose significant bits
fgets (record, filepointer);
^
readPolygon.c(53): error #165: too few arguments in function call
fgets (record, filepointer);
^
readPolygon.c(55): error: expected an expression
while (char !=NULL){
^
readPolygon.c(57): error: expression must have integral type
sscanf(filepointer, "%lf, %lf," &x, &y);
^
readPolygon.c(57): error: expression must have integral type
sscanf(filepointer, "%lf, %lf," &x, &y);
^
readPolygon.c(57): warning #167: argument of type "FILE *" is incompatible with parameter of type "const char *__restrict__"
sscanf(filepointer, "%lf, %lf," &x, &y);
^
readPolygon.c(58): error: a value of type "void" cannot be assigned to an entity of type "node *"
polygon = insertTail(polygon, x,y);
^
compilation aborted for readPolygon.c (code 2)