C++ meme program: creating an "animated desktop background" (epilepsy warning)
HTML-код
- Опубликовано: 3 июл 2024
- I have recently been spending a decent amount of time learning C++, which I have greatly enjoyed so far. (This partly explains why I haven't been uploading other videos recently!) I have very little programming ability at this point, but I thought I would still share some code for a "desktop background" that I created.
The actual program looks better in real life (which isn't saying much) than in this video given that much of my computer's power was dedicated to recording the monitor. Feel free to give it a download! It's available at github.com/kburchfiel/MemePro... .
I have been running this "program" on my computer for about 16 hours. It appears to be going through about 4,000-5000 numbers per second and the latest number just passed 280,000,000.
Once it makes it to 2,147,483,647 (which should take about 5-6 days), I'm expecting it to overflow and start adding up from -2,147,483,648 :)
Kenneth Burchfiel It would stop when it overflows since the for condition x>0 is no longer true
Oh you're right! I guess I would need to add in a separate "counter" variable to keep a continuous loop going.
Kenneth Burchfiel No just take away the condition x>0 and it will run forever
I wasn't able to get the for loop to run without x>0, so I just made a while(true) loop instead. The second version of the code now reads as follows:
#include
int x = 0;
int main()
{while (true) {x += 1;std::cout
My computer just finished counting to 2,187,483,647 with the new version of the program. And indeed, it then started counting upwards from what I imagine was -2,147,483,648.
funy