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

23
kapitel5/uniontest.c Normal file
View File

@@ -0,0 +1,23 @@
#include <stdio.h>
#include <string.h>
int main(void)
{
union myUnion /* Samma syntax som för struct */
{
int x;
float y;
char z[20];
} unionTest; /* Skapar en variabel unionTest ur myUnion */
printf("Storleken är %lu bytes\n",
(unsigned long int)sizeof(unionTest));
/* Endast unionTest.z nedan kommer innehålla ett riktigt värde */
unionTest.x = 500;
unionTest.y = 3.14;
strcpy(unionTest.z, "Hej hopp!");
printf("x = %d\ny = %f\nz = %s\n", unionTest.x, unionTest.y,
unionTest.z);
return 0;
}