Initial commit

This commit is contained in:
2021-10-01 20:24:05 +02:00
commit 860c025165
194 changed files with 4846 additions and 0 deletions

20
kapitel12/skriv-bin-ex1.c Normal file
View File

@@ -0,0 +1,20 @@
#include <stdio.h>
int main(void)
{
FILE *binfil;
float x;
/* Kontrollera om fopen lyckades öppna filen
i skrivläge */
if ( (binfil = fopen("flyttal.bin", "wb")) == 0 )
{
/* Skriv felmeddelande till stderr */
fprintf(stderr, "Kan inte skriva till fil\n");
return 1;
}
printf("Skriv ett flyttal: ");
scanf("%f", &x);
fwrite(&x, sizeof(x), 1, binfil);
fclose(binfil);
return 0;
}