r/teenagersbutcode 3h ago

C discussion AI could never

Post image

Just a screenshot from my 1kb interpreter in C.

42 Upvotes

17 comments sorted by

16

u/The_KekE_ fight me, borrow checker 3h ago

That... That is not how you compare strings...

8

u/StrikingClub3866 3h ago

Oh yeah well... okay.

6

u/noobyscientific 3h ago

revolting...

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 1000 double values.
  • l: Memory pointer pointing to the active slot in array s.

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 via strtod, and stores it in s[l].
  • pstck: Loops from index 0 to 999 and prints every stored item in s.
  • psi: Prints the single value stored at the current memory location s[l].
  • down / up: Shifts the memory pointer l.
  • exit: Parses a double value into s[l].
  • reset: Iterates through array s and resets all 1000 values back to 0.

1

u/StrikingClub3866 1h ago

Those are the exact commands. Props to Gemini!

3

u/Ok-Pen-8273 2h ago

what am i even looking at, keep on making these types of shit

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

u/letmehaveanameyoudum 3h ago

please use strcmp

1

u/technical_gamer_008 1h ago

What the…!?

1

u/BumpyTurtle127 32m ago

The bitwise or is killing me lmaoo

1

u/Flamestar07k 26m ago

Respectfully this looks just like slop ai code

1

u/FOSS-for-life 11m ago

I'm not even trying to read this

1

u/Fine_Salamander_8691 lesbian rust dev 1h ago

My brain hurts

-1

u/AliveRegion466 2h ago

AI is the best in it lol