46 lines
824 B
C
46 lines
824 B
C
#include<stdio.h>
|
|
|
|
/*use macro extern int errno*/
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
|
|
#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;
|
|
}
|