#include /*use macro extern int errno*/ #include #include #include "write-location-file.h" int main() { FILE *fp; /*latitude e.g. 52.26594*/ char lat [9]; /*longitude e.g. 10.52673*/ char lon [9]; printf("\nStart...\n"); fp = fopen("location.csv", "w"); if (fp==NULL) { /*failed to open file and associate stream*/ fprintf(stderr, "Value of errno: %d\n", errno); fprintf(stderr, "Error opening file: %s\n", strerror(errno)); } printf("\nEnter latitude: "); /*read from stdin*/ scanf(" %8s", lat); printf("\nlat: %s", lat); printf("\nEnter longitude: "); scanf(" %8s", lon); printf("\nlon: %s", lon); fprintf(fp, "%8s,%8s\n", lat, lon); fclose(fp); write_location_file("52.26594", "10.52673"); printf("\nDone!\n"); return 0; }