57 lines
1.3 KiB
C
57 lines
1.3 KiB
C
#include "write-location-file.h"
|
|
|
|
#include<stdio.h>
|
|
|
|
/*use macro extern int errno*/
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
|
|
int write_struct_location_file(struct location *lctn){
|
|
FILE *fp;
|
|
|
|
printf("\nwrite-struct-location-file() Start...\n");
|
|
|
|
printf("\nwrite-struct-location-file() lat: %s, lon: %s\n", lctn->lat, lctn->lon);
|
|
|
|
fp = fopen("struct-location-file.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));
|
|
}
|
|
|
|
/*latitude e.g. 52.26594*/
|
|
/*longitude e.g. 10.52673*/
|
|
fprintf(fp, "%s,%s\n", lctn->lat, lctn->lon);
|
|
fclose(fp);
|
|
|
|
printf("\nwrite-struct-location-file() Done!\n");
|
|
return 0;
|
|
}
|
|
|
|
int write_location_file(char *lat, char *lon){
|
|
FILE *fp;
|
|
|
|
printf("\nwrite-location-file() Start...\n");
|
|
|
|
printf("\nwrite-location-file() lat: %s, lon: %s\n", lat, lon);
|
|
|
|
fp = fopen("location-file.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));
|
|
}
|
|
|
|
/*latitude e.g. 52.26594*/
|
|
/*longitude e.g. 10.52673*/
|
|
fprintf(fp, "%s,%s\n", lat, lon);
|
|
fclose(fp);
|
|
|
|
printf("\nwrite-location-file() Done!\n");
|
|
return 0;
|
|
}
|
|
|