feat: add write-location-file

This commit is contained in:
dancingCycle 2023-01-02 16:58:24 +01:00
parent 66dc060c3e
commit 9ede7ca889
2 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,41 @@
#include<stdio.h>
/*use macro extern int errno*/
#include <errno.h>
#include <string.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);
printf("\nDone!\n");
return 0;
}

View File

@ -0,0 +1,9 @@
#put the most commonly desired target first (default)
all: main.o
gcc main.o -o write
main.o: main.c
gcc -I . -c main.c
clean:
rm -rf *.o
rm -rf write
rm -rf *.csv