Compare commits

..

4 Commits

Author SHA1 Message Date
040f9566df pa-06 2025-12-01 11:43:29 +01:00
1e70a6407d pa-04 2025-12-01 11:43:22 +01:00
bee4a89873 .gitignore 2025-11-24 10:36:22 +01:00
e92ee90050 pa-03 2025-11-24 10:36:08 +01:00
44 changed files with 1228 additions and 38 deletions

1
.clang-format Normal file
View File

@@ -0,0 +1 @@
IndentWidth: 4

2
.gitignore vendored
View File

@@ -0,0 +1,2 @@
.direnv
**/result

View File

@@ -1,23 +0,0 @@
with import <nixpkgs> {}; let
let isDir
let pDirs = builtins.readDir ./.;
script1 = writeShellScriptBin "script1" ''
echo "Hello from script1"
'';
script2 = writeShellScriptBin "script2" ''
echo "Hello from script2"
'';
in
stdenv.mkDerivation {
name = "all-scripts";
buildInputs = [
script1
script2
];
# Or use buildEnv to create a combined package
buildCommand = ''
mkdir -p $out
'';
}

View File

@@ -1,15 +0,0 @@
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
outputs = { self, nixpkgs }: {
packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello;
packages.x86_64-linux.default = self.packages.x86_64-linux.hello;
};
}

5
pa-03/a1/hello.c Normal file
View File

@@ -0,0 +1,5 @@
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}

11
pa-03/a2/calcggt.c Normal file
View File

@@ -0,0 +1,11 @@
#include <stdio.h>
#include "ggt.h"
int main() {
printf("ggt(9, 27) = %d\n", ggt(9, 27));
printf("ggt(12, 8) = %d\n", ggt(12, 8));
printf("ggt(0, 0) = %d\n", ggt(0, 0));
printf("ggt(1, 0) = %d\n", ggt(1, 0));
printf("ggt(0, 1) = %d\n", ggt(0, 1));
return 0;
}

61
pa-03/a2/flake.lock generated Normal file
View File

@@ -0,0 +1,61 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1763759067,
"narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1763835633,
"narHash": "sha256-HzxeGVID5MChuCPESuC0dlQL1/scDKu+MmzoVBJxulM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "050e09e091117c3d7328c7b2b7b577492c43c134",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1761765539,
"narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "719359f4562934ae99f5443f20aa06c2ffff91fc",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

53
pa-03/a2/flake.nix Normal file
View File

@@ -0,0 +1,53 @@
{
description = "Description for the project";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
# To import an internal flake module: ./other.nix
# To import an external flake module:
# 1. Add foo to inputs
# 2. Add foo as a parameter to the outputs function
# 3. Add here: foo.flakeModule
];
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: {
# Per-system attributes can be defined here. The self' and inputs'
# module parameters provide easy access to attributes of the same
# system.
# Equivalent to inputs'.nixpkgs.legacyPackages.hello;
packages.default = pkgs.stdenv.mkDerivation {
name = "ggt";
src = ./.;
buildPhase = ''
cc *.c -o calcggt.out
'';
installPhase = ''
mkdir -p $out/bin/
mv calcggt.out $out/bin/
'';
meta = {
mainProgram = "calcggt.out";
};
};
};
flake = {
# The usual flake attributes can be defined here, including system-
# agnostic ones like nixosModule and system-enumerating ones, although
# those are more easily expressed in perSystem.
};
};
}

6
pa-03/a2/ggt.c Normal file
View File

@@ -0,0 +1,6 @@
int ggt(int a, int b) {
// https://de.wikipedia.org/wiki/Gr%C3%B6%C3%9Fter_gemeinsamer_Teiler#Rechenregeln_f%C3%BCr_Zahlen
if (a == 0) return b;
if (b == 0) return a;
return ggt(b, a % b);
}

1
pa-03/a2/ggt.h Normal file
View File

@@ -0,0 +1 @@
int ggt(int a, int b);

61
pa-03/a3/flake.lock generated Normal file
View File

@@ -0,0 +1,61 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1763759067,
"narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1763835633,
"narHash": "sha256-HzxeGVID5MChuCPESuC0dlQL1/scDKu+MmzoVBJxulM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "050e09e091117c3d7328c7b2b7b577492c43c134",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1761765539,
"narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "719359f4562934ae99f5443f20aa06c2ffff91fc",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

52
pa-03/a3/flake.nix Normal file
View File

@@ -0,0 +1,52 @@
{
description = "Description for the project";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
# To import an internal flake module: ./other.nix
# To import an external flake module:
# 1. Add foo to inputs
# 2. Add foo as a parameter to the outputs function
# 3. Add here: foo.flakeModule
];
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: {
# Per-system attributes can be defined here. The self' and inputs'
# module parameters provide easy access to attributes of the same
# system.
packages.default = pkgs.stdenv.mkDerivation {
name = "a3";
src = ./.;
buildPhase = ''
cc main.c funktionen/*.c -o main.out
'';
installPhase = ''
mkdir -p $out/bin/
mv main.out $out/bin/
'';
meta = {
mainProgram = "main.out";
};
};
};
flake = {
# The usual flake attributes can be defined here, including system-
# agnostic ones like nixosModule and system-enumerating ones, although
# those are more easily expressed in perSystem.
};
};
}

View File

@@ -0,0 +1,13 @@
int to_ascii(char c) {
if (c >= 'A' && c <= 'Z') {
int ascii_A = 65;
int off = ascii_A - 'A';
return c + off;
}
if (c >= 'a' && c <= 'z') {
int ascii_a = 97;
int off = ascii_a - 'a';
return c + off;
}
return -1;
}

View File

@@ -0,0 +1 @@
int to_ascii(char c);

View File

@@ -0,0 +1,4 @@
int to_upper_case(char c) {
if (c >= 'A' && c <= 'Z') return c;
return c - ('a' - 'A');
}

View File

@@ -0,0 +1 @@
int to_upper_case(char c);

21
pa-03/a3/main.c Normal file
View File

@@ -0,0 +1,21 @@
#include "./funktionen/to_upper_case.h"
#include "./funktionen/to_ascii.h"
#include <stdio.h>
int main() {
printf("Beenden von Schleifen mit ~ ...\n");
printf("Geben sie Zeichen ein. Diese werden in Uppercase wieder ausgegeben:\n");
while (1) {
int c = getchar();
if (c == '~') break;
printf("[%d] %c", c, to_upper_case(c));
}
printf("Geben sie Zeichen ein. Diese werden als Ascii-Code wieder ausgegeben:\n");
while (1) {
int c = getchar();
if (c == '~') break;
printf("[%d] %d", c, to_ascii(c));
}
return 0;
}

61
pa-03/a4/flake.lock generated Normal file
View File

@@ -0,0 +1,61 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1763759067,
"narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1763835633,
"narHash": "sha256-HzxeGVID5MChuCPESuC0dlQL1/scDKu+MmzoVBJxulM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "050e09e091117c3d7328c7b2b7b577492c43c134",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1761765539,
"narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "719359f4562934ae99f5443f20aa06c2ffff91fc",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

52
pa-03/a4/flake.nix Normal file
View File

@@ -0,0 +1,52 @@
{
description = "Description for the project";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
# To import an internal flake module: ./other.nix
# To import an external flake module:
# 1. Add foo to inputs
# 2. Add foo as a parameter to the outputs function
# 3. Add here: foo.flakeModule
];
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: {
# Per-system attributes can be defined here. The self' and inputs'
# module parameters provide easy access to attributes of the same
# system.
packages.default = pkgs.stdenv.mkDerivation {
name = "a3";
src = ./.;
buildPhase = ''
cc test.c funktionen/*.c -o test.out
'';
installPhase = ''
mkdir -p $out/bin/
mv test.out $out/bin/
'';
meta = {
mainProgram = "test.out";
};
};
};
flake = {
# The usual flake attributes can be defined here, including system-
# agnostic ones like nixosModule and system-enumerating ones, although
# those are more easily expressed in perSystem.
};
};
}

18
pa-03/a4/test.c Normal file
View File

@@ -0,0 +1,18 @@
#include <stdio.h>
void ascii(int s) {
if (s < 1) s = 1;
for (char c = 32; c <= 126;) {
for (int i = 0; i < s && c <= 126; i++) {
printf("%3d %c ", c, c);
c++;
}
printf("\n");
}
}
int main() {
ascii(5);
return 0;
}

61
pa-04/a1/flake.lock generated Normal file
View File

@@ -0,0 +1,61 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1763759067,
"narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1763835633,
"narHash": "sha256-HzxeGVID5MChuCPESuC0dlQL1/scDKu+MmzoVBJxulM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "050e09e091117c3d7328c7b2b7b577492c43c134",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1761765539,
"narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "719359f4562934ae99f5443f20aa06c2ffff91fc",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

52
pa-04/a1/flake.nix Normal file
View File

@@ -0,0 +1,52 @@
{
description = "Description for the project";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
# To import an internal flake module: ./other.nix
# To import an external flake module:
# 1. Add foo to inputs
# 2. Add foo as a parameter to the outputs function
# 3. Add here: foo.flakeModule
];
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: {
# Per-system attributes can be defined here. The self' and inputs'
# module parameters provide easy access to attributes of the same
# system.
packages.default = pkgs.stdenv.mkDerivation {
name = "a1";
src = ./.;
buildPhase = ''
cc main.c funktionen/*.c -o main.out
'';
installPhase = ''
mkdir -p $out/bin/
mv main.out $out/bin/
'';
meta = {
mainProgram = "main.out";
};
};
};
flake = {
# The usual flake attributes can be defined here, including system-
# agnostic ones like nixosModule and system-enumerating ones, although
# those are more easily expressed in perSystem.
};
};
}

9
pa-04/a1/main.c Normal file
View File

@@ -0,0 +1,9 @@
#include <stdio.h>
int main() {
printf("Der Datentyp char ist %d Byte lang.\n", sizeof(char));
printf("Der Datentyp int ist %d Byte lang.\n", sizeof(int));
printf("Der Datentyp long ist %d Byte lang.\n", sizeof(long));
printf("Der Datentyp float ist %d Byte lang.\n", sizeof(float));
printf("Der Datentyp double ist %d Byte lang.\n", sizeof(double));
return 0;
}

61
pa-04/a2/flake.lock generated Normal file
View File

@@ -0,0 +1,61 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1763759067,
"narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1763835633,
"narHash": "sha256-HzxeGVID5MChuCPESuC0dlQL1/scDKu+MmzoVBJxulM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "050e09e091117c3d7328c7b2b7b577492c43c134",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1761765539,
"narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "719359f4562934ae99f5443f20aa06c2ffff91fc",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

52
pa-04/a2/flake.nix Normal file
View File

@@ -0,0 +1,52 @@
{
description = "Description for the project";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
# To import an internal flake module: ./other.nix
# To import an external flake module:
# 1. Add foo to inputs
# 2. Add foo as a parameter to the outputs function
# 3. Add here: foo.flakeModule
];
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: {
# Per-system attributes can be defined here. The self' and inputs'
# module parameters provide easy access to attributes of the same
# system.
packages.default = pkgs.stdenv.mkDerivation {
name = "a2";
src = ./.;
buildPhase = ''
cc main.c funktionen/*.c -o main.out
'';
installPhase = ''
mkdir -p $out/bin/
mv main.out $out/bin/
'';
meta = {
mainProgram = "main.out";
};
};
};
flake = {
# The usual flake attributes can be defined here, including system-
# agnostic ones like nixosModule and system-enumerating ones, although
# those are more easily expressed in perSystem.
};
};
}

27
pa-04/a2/main.c Normal file
View File

@@ -0,0 +1,27 @@
#include <stdio.h>
#include <string.h>
int main() {
char foo[4] = "foo";
char bar[4] = "bar";
printf("foo ist %d Zeichen lang\n", (int)strlen(foo));
printf("foo: %s \n", foo);
printf("bar: %s \n", bar);
char foobar[7];
strcpy(foobar, foo);
printf("foobar: %s \n", foobar);
strcat(foobar, bar);
printf("foo ++ bar -> foobar: %s \n", foobar);
if (strcmp(foo, bar) == 0) {
printf("foo = bar \n");
}
else {
printf("foo != bar \n");
}
return 0;
}

0
pa-04/a3/.clang-format Normal file
View File

61
pa-04/a3/flake.lock generated Normal file
View File

@@ -0,0 +1,61 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1763759067,
"narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1763835633,
"narHash": "sha256-HzxeGVID5MChuCPESuC0dlQL1/scDKu+MmzoVBJxulM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "050e09e091117c3d7328c7b2b7b577492c43c134",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1761765539,
"narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "719359f4562934ae99f5443f20aa06c2ffff91fc",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

52
pa-04/a3/flake.nix Normal file
View File

@@ -0,0 +1,52 @@
{
description = "Description for the project";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
# To import an internal flake module: ./other.nix
# To import an external flake module:
# 1. Add foo to inputs
# 2. Add foo as a parameter to the outputs function
# 3. Add here: foo.flakeModule
];
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: {
# Per-system attributes can be defined here. The self' and inputs'
# module parameters provide easy access to attributes of the same
# system.
packages.default = pkgs.stdenv.mkDerivation {
name = "a3";
src = ./.;
buildPhase = ''
cc main.c funktionen/*.c -o main.out
'';
installPhase = ''
mkdir -p $out/bin/
mv main.out $out/bin/
'';
meta = {
mainProgram = "main.out";
};
};
};
flake = {
# The usual flake attributes can be defined here, including system-
# agnostic ones like nixosModule and system-enumerating ones, although
# those are more easily expressed in perSystem.
};
};
}

9
pa-04/a3/main.c Normal file
View File

@@ -0,0 +1,9 @@
#include <stdio.h>
int main(int argc, char *argv[]) {
/* Schleife ueber alle Argumente */
for (int i = 0; i < argc; i++) {
/* Ausgabe zeilenweise */
printf("Argument %d: %s\n", i, argv[i]);
}
return 0;
}

0
pa-04/a4/.clang-format Normal file
View File

61
pa-04/a4/flake.lock generated Normal file
View File

@@ -0,0 +1,61 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1763759067,
"narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1763835633,
"narHash": "sha256-HzxeGVID5MChuCPESuC0dlQL1/scDKu+MmzoVBJxulM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "050e09e091117c3d7328c7b2b7b577492c43c134",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1761765539,
"narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "719359f4562934ae99f5443f20aa06c2ffff91fc",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

52
pa-04/a4/flake.nix Normal file
View File

@@ -0,0 +1,52 @@
{
description = "Description for the project";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
# To import an internal flake module: ./other.nix
# To import an external flake module:
# 1. Add foo to inputs
# 2. Add foo as a parameter to the outputs function
# 3. Add here: foo.flakeModule
];
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: {
# Per-system attributes can be defined here. The self' and inputs'
# module parameters provide easy access to attributes of the same
# system.
packages.default = pkgs.stdenv.mkDerivation {
name = "a4";
src = ./.;
buildPhase = ''
cc main.c funktionen/*.c -o main.out
'';
installPhase = ''
mkdir -p $out/bin/
mv main.out $out/bin/
'';
meta = {
mainProgram = "main.out";
};
};
};
flake = {
# The usual flake attributes can be defined here, including system-
# agnostic ones like nixosModule and system-enumerating ones, although
# those are more easily expressed in perSystem.
};
};
}

17
pa-04/a4/main.c Normal file
View File

@@ -0,0 +1,17 @@
#include <stdio.h>
int main(void) {
int a;
int *aptr;
char hello[] = "Hello, World!\n";
char *hptr;
a = 10;
aptr = &a;
printf("a: %d\n", *aptr);
hptr = hello + 7;
printf("%s\n", hptr);
while (*hptr) {
printf("%c ", *hptr++);
}
printf("\n");
return 0;
}

61
pa-04/a5/flake.lock generated Normal file
View File

@@ -0,0 +1,61 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1763759067,
"narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1763835633,
"narHash": "sha256-HzxeGVID5MChuCPESuC0dlQL1/scDKu+MmzoVBJxulM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "050e09e091117c3d7328c7b2b7b577492c43c134",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1761765539,
"narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "719359f4562934ae99f5443f20aa06c2ffff91fc",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

52
pa-04/a5/flake.nix Normal file
View File

@@ -0,0 +1,52 @@
{
description = "Description for the project";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
# To import an internal flake module: ./other.nix
# To import an external flake module:
# 1. Add foo to inputs
# 2. Add foo as a parameter to the outputs function
# 3. Add here: foo.flakeModule
];
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: {
# Per-system attributes can be defined here. The self' and inputs'
# module parameters provide easy access to attributes of the same
# system.
packages.default = pkgs.stdenv.mkDerivation {
name = "a5";
src = ./.;
buildPhase = ''
cc main.c funktionen/*.c -o main.out
'';
installPhase = ''
mkdir -p $out/bin/
mv main.out $out/bin/
'';
meta = {
mainProgram = "main.out";
};
};
};
flake = {
# The usual flake attributes can be defined here, including system-
# agnostic ones like nixosModule and system-enumerating ones, although
# those are more easily expressed in perSystem.
};
};
}

15
pa-04/a5/main.c Normal file
View File

@@ -0,0 +1,15 @@
#include <stdio.h>
void funk(int *a) {
a[0] = 1;
a[1] = 2;
a[2] = 3;
}
int main() {
/* Vektor c deklarieren und Speicherplatz fuer 3 Elemente auf dem Stack
* reservieren */
int c[3];
/* Funktion funk aufrufen, funk speichert 3 Werte im Vektor c */
funk(c);
printf("c[0] = %d, c[1] = %d, c[2] = %d\n", c[0], c[1], c[2]);
return 0;
}

6
pa-06/a2/a.c Normal file
View File

@@ -0,0 +1,6 @@
#include <stdio.h>
#include <unistd.h>
int main(void) {
printf("Guten Tag %d\n", fork());
return 0;
}

6
pa-06/a2/b.c Normal file
View File

@@ -0,0 +1,6 @@
#include <stdio.h>
#include <unistd.h>
int main(void) {
printf("Guten %d Tag %d\n", fork(), fork());
return 0;
}

7
pa-06/a2/c.c Normal file
View File

@@ -0,0 +1,7 @@
#include <stdio.h>
#include <unistd.h>
int main(void) {
printf("Guten %d\n", fork());
printf("Tag %d\n", fork());
return 0;
}

21
pa-06/a2/d.c Normal file
View File

@@ -0,0 +1,21 @@
#include <stdio.h>
#include <unistd.h>
int main(void) {
int v1 = 0, v2 = 0, v3 = 0, pid;
pid = getpid();
v2++;
if (fork()) {
v1++;
v2++;
sleep(1);
if (fork()) {
v1++;
sleep(1);
}
}
if (pid == getppid()) {
v3++;
}
printf("%d %d %d\n", v1, v2, v3);
return 0;
}

61
pa-06/a2/flake.lock generated Normal file
View File

@@ -0,0 +1,61 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1763759067,
"narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1763835633,
"narHash": "sha256-HzxeGVID5MChuCPESuC0dlQL1/scDKu+MmzoVBJxulM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "050e09e091117c3d7328c7b2b7b577492c43c134",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1761765539,
"narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "719359f4562934ae99f5443f20aa06c2ffff91fc",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

60
pa-06/a2/flake.nix Normal file
View File

@@ -0,0 +1,60 @@
{
description = "Description for the project";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
# To import an internal flake module: ./other.nix
# To import an external flake module:
# 1. Add foo to inputs
# 2. Add foo as a parameter to the outputs function
# 3. Add here: foo.flakeModule
];
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: {
# Per-system attributes can be defined here. The self' and inputs'
# module parameters provide easy access to attributes of the same
# system.
packages = let
mkTask = part:
pkgs.stdenv.mkDerivation {
name = "a1-${part}";
src = ./.;
buildPhase = ''
cc ${part}.c -o ${part}.out
'';
installPhase = ''
mkdir -p $out/bin/
mv ${part}.out $out/bin/
'';
meta = {
mainProgram = "${part}.out";
};
};
in {
a = mkTask "a";
b = mkTask "b";
c = mkTask "c";
d = mkTask "d";
};
};
flake = {
# The usual flake attributes can be defined here, including system-
# agnostic ones like nixosModule and system-enumerating ones, although
# those are more easily expressed in perSystem.
};
};
}

View File

@@ -3,6 +3,7 @@ with import <nixpkgs> {};
packages = [
gnumake
libgcc
llvmPackages_20.clang-tools
bsd-finger
];
shellHook = ''