Programming Thread

Started by the-pi-guy, Mar 13, 2016, 10:39 PM

previous topic - next topic

0 Members and 3 Guests are viewing this topic.

Go Down

the-pi-guy

So, people.  

What was a bad programming mistake you made?  

the-pi-guy

Oct 08, 2017, 09:33 PM Last Edit: Oct 08, 2017, 09:38 PM by the-pi-guy
I'm having some issues with C.  
I'm trying to compare two strings...  And the stack overflow solution isn't working at all.  

For some reason trying to print out:
Char s[100];
print(s[0]);

This code prints the entire array.

Legend

So, people.  

What was a bad programming mistake you made?  
I make infinite loops far too commonly.

I'm having some issues with C.  
I'm trying to compare two strings...  And the stack overflow solution isn't working at all.  

For some reason trying to print out:
Char s[100];
print(s[0]);

This code prints the entire array.
Does s[1] also print the whole array?

the-pi-guy

I make infinite loops far too commonly.
Does s[1] also print the whole array?
I figured out part of it.  
I was misusing pointer stuff.
s[1] prints out the whole array minus the first character.  

the-pi-guy

For some reason one print line executes and the one underneath it doesn't. 
C is upsetting... 

the-pi-guy

It's really crazy all the things that an OS does.  

Basically every time period, the OS basically does a "context switch", the OS gets reloaded into the computer many, many times a second.  
Learning about the program counter in a few different classes.  Like the computer stores what line of code it is reading.  

It just feels so weird to think about with how nice OS's are, that basically every second, every program stops running for a very tiny portion of time, gets switched to something else, and back again before anyone notices.  

This semester seems like a lot of obvious things that still seem weird to think about.  Like it's obvious the OS has to work that way, but then it seems crazy at the same time.  

Another thing that is obvious, but just seems so counter to experience, is that programming languages vary from compiler and OS.  

Usually you work in 1 compiler, 1 OS, so you don't notice these things all the time.  
But it's just weird sometimes how little things can completely wreck your program on someone else's computer.  (Obvious.)  

Like this:
for(int i=0; i<20; i++)

Works perfectly fine on my computer at home on a Linux OS.  It doesn't work on the school computers.  Instead this does:
int i;
for(i=0; i<20; i++)

the-pi-guy

I spent a while working on my assignment and was frustrated.  

Spent 20 minutes looking at someone else's code, also frustrated.  Then it suddenly made complete sense.  

Walked back to my own assignment, and suddenly for no reason it suddenly made sense.  I suddenly came up with an idea on the spot that fixed my issues from the past few hours.  

the-pi-guy

Computers be like:
"10+10=100"
"11+11=110"
"101*1101=1000001"

Legend

Computers be like:
"10+10=100"
"11+11=110"
"101*1101=1000001"
I mean yes that be factual.

the-pi-guy

I mean yes that be factual.
I think someone who doesn't know binary would be very confused that 10+10 =100.

darkknightkryta

I'm having some issues with C.  
I'm trying to compare two strings...  And the stack overflow solution isn't working at all.  

For some reason trying to print out:
Char s[100];
print(s[0]);

This code prints the entire array.
Why not sure printf?
printf("%c",s[0]);

the-pi-guy

Why not sure printf?
printf("%c",s[0]);
I meant printf.  
But that's probably why it was outputting the whole array.  

darkknightkryta

I meant printf.  
But that's probably why it was outputting the whole array.  
Yeah the way you were using printf was just all kinds of wrong so I wasn't sure if there was an actual print command in C.

the-pi-guy

Increasing cache memory can actually decrease performance if using a FIFO algorithm.  

It never hurts performance in least frequent or least recent algorithms.

But for FIFO, there are work loads where having a smaller cache gives better results.  

Tachikoma

So, people.  

What was a bad programming mistake you made?  
I once ported some code to the wiiu, what a waste.

Go Up