anton
As a cis guy, I rarely use emojis other than thumbs up, but that doesn't make me any more masculine than you.
Please don't measure yourself by toxic stereotypes like men are power hungry brutes that see any display of emotions as weakness.
Bis auf des Video im Regen ging es für mich, aber wie da die Laune ist, kann sehr unterschiedlich sein.
🏳️⚧️ Gratulation an Frau Lindner und die anderen zum Rauskommen 🏳️⚧️
I heard the mathematicians have a way to describe this profound relationship: Dolphins ⊂ Whales
Auf dem Arduino kannst du keine Dateien lesen, es sei den du willst die über serial senden, deshalb musst du die Werte in dein Programm kompilieren.
will eher ungerne den User in einer C-Header Datei rum spielen lassen
Dann lass deine user deine config schreiben und generiere eine header Datei daraus.
Ich habe mal meine C-Kenntnisse raus gekramt.
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#define BUFFER_LEN 1024
#define MIN_STRONG_SIZE 16
#define IN_FILE_DEFAULT "config.txt"
#define OUT_FILE_DEFAULT "config.h"
typedef struct String {
size_t length;
size_t size;
char content[];
} String;
typedef struct Variable {
String* name;
int intPart;
int fracPart;
bool isNegative;
bool hasFraction;
} Variable;
FILE* outFile;
void storeVariable(Variable variable) {
fprintf(outFile, "#define VAR_%s ", variable.name->content);
if (variable.isNegative)
fprintf(outFile, "-");
fprintf(outFile, "%d", variable.intPart);
if (variable.hasFraction)
fprintf(outFile, ".%d", variable.fracPart);
fprintf(outFile, "\n");
free(variable.name);
}
String* newString(size_t size) {
if (size < MIN_STRONG_SIZE) {
size = MIN_STRONG_SIZE;
}
String* string = calloc(1, sizeof(String) + size);
if (string == NULL) {
fprintf(stderr, "allocation error");
exit(3);
}
string->size = size;
return string;
}
String* appendToString(String* string, char c) {
if (string == NULL) {
fprintf(stderr, "null pointer error");
exit(4);
}
if (string->length+1 >= string->size) {
string->size *= 2;
string = realloc(string, sizeof(String) + string->size);
if (string == NULL) {
fprintf(stderr, "allocation error");
exit(3);
}
}
string->content[string->length] = c;
string->content[string->length+1] = '\0';
string->length++;
return string;
}
typedef enum ParseMode {
VAR_NAME_START = 0,
VAR_NAME,
INTEGER_START,
INTEGER,
FRACTION,
} ParseMode;
void handleChar(char c);
int main(int argc, char** argv) {
char* confFileName = IN_FILE_DEFAULT;
char* headerFileName = OUT_FILE_DEFAULT;
if (argc > 1) {
if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
printf("usage: %s config_file output_file\n", argv[0]);
printf("if no files get specified, the defaults are: %s %s\n", IN_FILE_DEFAULT, OUT_FILE_DEFAULT);
return 0;
}
confFileName = argv[1];
}
if (argc > 2) {
headerFileName = argv[2];
}
FILE* file = fopen(confFileName, "r");
if (file == NULL) {
fprintf(stderr, "can't open input file %s", confFileName);
return 1;
}
outFile = fopen(headerFileName, "w");
if (outFile == NULL) {
fprintf(stderr, "can't open output file %s", headerFileName);
return 1;
}
char buffer[BUFFER_LEN];
unsigned long amountRead = fread(buffer, 1, BUFFER_LEN, file);
while (amountRead > 0) {
for (int i = 0; i < amountRead; i++) {
handleChar(buffer[i]);
}
amountRead = fread(buffer, 1, BUFFER_LEN, file);
}
handleChar('\n');
fclose(file);
fclose(outFile);
return 0;
}
ParseMode mode;
Variable state = {0};
void handleChar(char c) {
if (c == ' ') {
return;
}
switch (mode) {
case VAR_NAME_START:
if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) {
state.name = newString(20);
state.name = appendToString(state.name, c);
mode = VAR_NAME;
} else {
fprintf(stderr, "error on '%c': variable names must start with a letter", c);
exit(2);
}
break;
case VAR_NAME:
if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || (c == '_')) {
state.name = appendToString(state.name, c);
} else if (c == '=') {
mode = INTEGER;
} else {
fprintf(stderr, "name error on '%c': variable names consist of alphanumeric characters and underscores", c);
exit(2);
}
break;
case INTEGER_START:
if (c == '-') {
state.isNegative = true;
state.intPart = 0;
} else if ('0' <= c && c <= '9') {
state.intPart = c - '0';
} else {
fprintf(stderr, "number error on '%c': expected digit or '-'", c);
exit(2);
}
break;
case INTEGER:
if ('0' <= c && c <= '9') {
state.intPart = state.intPart * 10 + c - '0';
} else if (c == '\n') {
mode = VAR_NAME_START;
storeVariable(state);
Variable empty = {0};
state = empty;
} else if (c == '.') {
mode = FRACTION;
state.hasFraction = true;
} else {
fprintf(stderr, "number error on '%c': expected digit or '.'", c);
exit(2);
}
break;
case FRACTION:
if ('0' <= c && c <= '9') {
state.intPart = state.intPart * 10 + c - '0';
} else if (c == '\n') {
mode = VAR_NAME_START;
storeVariable(state);
Variable empty = {0};
state = empty;
} else {
fprintf(stderr, "number error on '%c': expected digit", c);
exit(2);
}
break;
}
}
Man sollte es wahrscheinlich in header und source aufteilen, und die strings sind vielleicht overkill, aber für ein one-of pass es schon. Wenn die variablen nach dem parsen anders verwenden willst, musst du nur storeVariable
abändern.
Doing regular physical sports is certainly a thing some esports teams do, but 30m seems a little short.
I like self directed research, it's mostly rust stuff, but has some really interesting topics mixed in.
There needs to be a clear legal standard, and 18 Years is the arbitrary line we agreed on.
When a 17 Year old go to war, they are child soldiers, and when they get bombed/starve, they count towards the children death toll.
To me emojis are more age than gender coded.
For example most young people I know (with the exception of one teenage boy) are similarly sparse with emojis as I am, and if you sprinkle some of 😄😎😳🤗🥰🤩 in and you can fit in with boomers and gen x of any gender.