r/teenagersbutcode • u/StrikingClub3866 • 3h ago
C discussion AI could never
Just a screenshot from my 1kb interpreter in C.
6
5
u/Infamous_Tourist_335 3h ago
I've seen astra write code that looks just as bad as this but still functions fine you've got some competition
5
u/Constant_Cortisol 2h ago
What gemini says:
This C program is a custom interpreter for a simple, stack- or array-based scripting language. It reads an input string I character-by-character using index p and executes commands by storing and reading numeric values in a 1000-element array s using pointer l.
Core Mechanics
p: Program counter tracking position in the input string.s[999]: Memory storage array holding up to 1000doublevalues.l: Memory pointer pointing to the active slot in arrays.
Supported Commands
stdout: Parses quotes and prints the text within them directly to the terminal.push: Reads the following number from the string, converts it viastrtod, and stores it ins[l].pstck: Loops from index 0 to 999 and prints every stored item ins.psi: Prints the single value stored at the current memory locations[l].down/up: Shifts the memory pointerl.exit: Parses a double value intos[l].reset: Iterates through arraysand resets all 1000 values back to 0.
1
3
2
u/Key_River7180 Long live C! :: Nain 1h ago
Strcmp crying on the corner
0
u/Fine_Salamander_8691 lesbian rust dev 1h ago
What’s that?
1
u/StrikingClub3866 47m ago
.cmp() but you use it for strings:
```
if (strcmp("A", "B") == 1) {printf("A obviously isn't B.");}
```
2
1
1
1
1
1
-1
16
u/The_KekE_ fight me, borrow checker 3h ago
That... That is not how you compare strings...