Programming Thread

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

previous topic - next topic

0 Members and 4 Guests are viewing this topic.

Go Down

Legend

Working on an assignment due tonight.

I have a variable that is being changed between print statements, despite the fact the only time that variable gets changed is when it gets set originally.
I just had an issue like that!

In c# I replaced the variable with a function that acted like a variable. Then it could print a message everytime it was changed and tell me who changed it. Does c++ have similar?

the-pi-guy

Dec 16, 2017, 02:26 AM Last Edit: Dec 16, 2017, 02:50 AM by the-pi-guy
I just had an issue like that!

In c# I replaced the variable with a function that acted like a variable. Then it could print a message everytime it was changed and tell me who changed it. Does c++ have similar?
I think it's possible to have a pointer variable, that points to a function. 
Never tried it, but I recall reading something about it. 


I just had an issue like that!

In c# I replaced the variable with a function that acted like a variable. Then it could print a message everytime it was changed and tell me who changed it. Does c++ have similar?
I've been messing around some more. 

For some reason, this method is changing the value.  literally one line:
Code: [Select]

int getSize(int i)
return list[i].size;

the-pi-guy

I just had an issue like that!

In c# I replaced the variable with a function that acted like a variable. Then it could print a message everytime it was changed and tell me who changed it. Does c++ have similar?
So what the assignment is, is to implement malloc (memory allocation).
But it requires a data structure to keep track of data locations.  

I was using an array that would change length, by getting reassigned basically.  

But apparently assigning the arrays that way has some unusual behaviors.  

I changed all the declarations to utilizing malloc, which feels wrong.  Now it works great.  

It's apparently fine if the data structure uses malloc, but eh I don't like it.  

darkknightkryta

Dec 16, 2017, 06:56 PM Last Edit: Dec 16, 2017, 06:59 PM by darkknightkryta
I think it's possible to have a pointer variable, that points to a function.  
Never tried it, but I recall reading something about it.  

I've been messing around some more.  

For some reason, this method is changing the value.  literally one line:
Code: [Select]

int getSize(int i)
return list[i].size;

Yes you can make a variable point to a function.  I vaguely recall it being in a lab.  Not sure why'd you would use it.

So what the assignment is, is to implement malloc (memory allocation).
But it requires a data structure to keep track of data locations.  

I was using an array that would change length, by getting reassigned basically.  

But apparently assigning the arrays that way has some unusual behaviors.  

I changed all the declarations to utilizing malloc, which feels wrong.  Now it works great.  

It's apparently fine if the data structure uses malloc, but eh I don't like it.  
Memory related issues are the hardest to debug.  C's memory system isn't that good either (Was at the time I guess).  Though as I tell all my students "Be kind to C and C will be kind to you"  So use malloc and like it :P

the-pi-guy

Yes you can make a variable point to a function.  I vaguely recall it being in a lab.  Not sure why'd you would use it.
Memory related issues are the hardest to debug.  C's memory system isn't that good either (Was at the time I guess).  Though as I tell all my students "Be kind to C and C will be kind to you"  So use malloc and like it :P
How can I use malloc if I'm trying to implement malloc?  

darkknightkryta

How can I use malloc if I'm trying to implement malloc?  

Implement malloc?  You have to inline assembly for that...

Legend

Dec 20, 2017, 01:30 AM Last Edit: Dec 20, 2017, 03:59 AM by Legend
I'm having a stupid thing and I don't understand.

In Unity objects have a forward vector, a right vector, and an up vector. These are the calculus kind, not the c++ kind. I have a custom vector that's defined by a quaternion*vector, then multiplied by the object's rotation.

Something is screwing up because through testing I've realised that even if an object has two of these custom vectors defined, it can be in multiple rotations. Should be mathematically impossible but I really don't understand where my mistake is. Visually my custom vectors seem to function properly.

edt: figured it out!!!!!!!! my custom vectors were 180 degrees opposite of eachother so the system had issues. I should have checked on that possibility sooner.

edt2: well now it's not creating the full amount of vectors! I shouldn't program when this tired...

the-pi-guy

What do you mean multiple rotations?  Why is it impossible?

Legend

What do you mean multiple rotations?  Why is it impossible?
If you define an object's forward direction and it's upwards direction, then you've fully defined its rotation. There is only one state it can be in. My forward and upward directions were accidentally opposite so the second vector didn't actually define anything new.

the-pi-guy

Feb 02, 2018, 03:56 AM Last Edit: Feb 02, 2018, 04:02 AM by the-pi-guy
Pi created his first server!

It plays a code breaking game with a client.
It's cool.

Legend

Pi created his first server!

It plays a code breaking game with a client.
It's cool.
So are you hosting it?

the-pi-guy

So are you hosting it?
Well the server and the client are both being run on the same machine.  

Right now it's only set up to take one client, and then it shuts down.  

darkknightkryta

Yeah I need to get back into figuring out server programming.  I need to make my "gameification" of learning.  I have a whole JRPG idea for going through lessons and completing quizzes.  Gonna take me a while though.

the-pi-guy

Next server is multithreaded!
Many threads. Many clients.

the-pi-guy

Feb 10, 2018, 12:12 AM Last Edit: Feb 10, 2018, 12:21 AM by the-pi-guy
So are you hosting it?
It seems to be as easy as changing the hostname in the server program to be able to do it over the internet.  

Would someone like to try?  :D

Actually maybe it doesn't work yet.  

I'm not sure how much of my errors is because something isn't set up right or because the computers aren't allowing it on campus.  

And I'm not sure how much trouble I could get into.  

Go Up