to Allocate memory is an easy process but to allocate memory properly is a tricky part and it helps make you're program more efficient.
So how to allocate memory properly :
1- create a pointer to use it to pint at the memory.
2- Allocate memory and set it or assign it to what you need .
3- Use the Memory in you're program.
4- De allocate the memory allocated.
that seems pretty forward and easy but what really hard is when you find the memory is too big or too small for your data so you create another array ! wrong that causes a memory leak. The programmer needs to reallocate memory.
How to reallocate memory :
1-Create temporary pointer
2- allocate the size of memory you need to use .
3- copy old data to new array .
4- de allocate old memory.
5- use the original pointer point to the new memory.
6- Don't delete temporary pointer it's gonna be deleted automatically.
The point of doing all of these is keeping your program out of pugs.
Thursday, February 25, 2010
Memory Allocation
Posted by Gamal Tawaf at 9:09 PM 0 comments
Labels: Seneca
Monday, February 8, 2010
String Vs Charecters
I had a code thet used " " to display a single space but it gave me a crazy answer like it showed <. I didn't know what to do so I asked freind
this is the code : http://pastebin.ca/1790805
this is why it showed < :
so I know now what was my problem and my code is
working nicely now thanks tdot
Posted by Gamal Tawaf at 5:20 PM 0 comments
Labels: Seneca
Thursday, January 21, 2010
OOP344 - Using SVN
I learned today how to use SVN :
1) Check out: to get the code out of the repository.
2) Work with code :
A) add : is to add information to the repository.
B) Modify or Edit : to change and fix the code you have.
3)Update : to make sure your code is up to date if any member has changed any thing .
4) Commit : to commit the changes you've made to the code
I learned that
for (i=0,j=0;i<10;i++,j++){//some code
}
is the same as
i=0;
j=0;
while (i<10){//somecode
i++;
j++;
}
and that
for (i=0,j=0;i<10;i++,j++){//some code
}
it's okay to put two operations in the same place in the for loop as long as they are separated by comma( ,)
but it's ot okay to put two comma seprated operations at the condition part becuase it doesnt' make sense like
for (i=0,j=0;i<10,j<10;i++,j++){//some code
}
in this case which one is the condition so if you want them to be executed together you can join them with && or ||
I enjoyed learning these things
Posted by Gamal Tawaf at 3:23 PM 0 comments
Labels: Seneca
Monday, January 18, 2010
OOP344 class Canceled
I've been looking forward to take the assessment test in the OOP344 class but the teacher canceled the class because he was sick.I wish he gets better for next class and I hope I won't be late to class as last time.OOP344 is looking very nice I've learned some stuff that I didn't know about. The teacher is great he keeps us active the whole class.
Posted by Gamal Tawaf at 12:09 PM 0 comments
Labels: Seneca
Saturday, January 16, 2010
OOP344 calss
I had a nice class last week,I was an hour late though.We studied about SVN .We are gonna have a quiz next week .The first week was nice as expected.I wish that the rest of the semester stay the same.
Posted by Gamal Tawaf at 1:57 PM 0 comments
Labels: Seneca
Tuesday, January 12, 2010
Teacher's strike
It's unfair to have students pay for teachers not satisfied with their contracts.If they went in strike we're gonna be the biggest loser.
Posted by Gamal Tawaf at 8:22 PM 0 comments
Monday, January 11, 2010
OOP 344 teacher was great but he asked us to form groups with in one week.
I don't see how is that possible.We should at least have two weeks to know each other.
Posted by Gamal Tawaf at 4:57 PM 0 comments
Labels: Seneca