Hot answers tagged

5 votes

CS50 FAQ's and answers

Pset4 submission problems For people having trouble submitting the .zip file for pset4: 1) One option is to remove the SPL library from the folder and then zipping and submitting. 2) In case you ...
user avatar
  • 1,677
4 votes
Accepted

When we free a dynamically allocated memory, what happens to the pointer pointing at it?

Yes, when you use a free(px); call, it frees the memory that was malloc'd earlier and pointed to by px. The pointer itself, however, will continue to exist and will still have the same address. It ...
user avatar
  • 63.4k
3 votes
Accepted

Memory allocation: recommended practices

I'm not sure you needed to learn about pointers and memory management in order to solve hacker 2. I think you've gone a little bit far. However, I'm gonna try answering your questions. A pointer is ...
user avatar
  • 17.4k
2 votes
Accepted

What will realloc() do if the contiguous memory location is already occupied?

The answer of our friend @NullityNull is correct, as long as realloc succeeds and works well. Your question is interesting. Consider the following program fragment char *string; string = (char *)...
user avatar
  • 5,172
2 votes

What will realloc() do if the contiguous memory location is already occupied?

If realloc can't resize the memory block you pass in, it makes a new one, copies the data, and deallocates the old one. If I were you I'd read up a bit on specification for Realloc and malloc.
user avatar
1 vote

PHP removal from CS50

Disclaimer: I am not part of CS50 team, and don't know their reasoning. This is my opinion, why I think that has been a good idea, especially when touching currently trendy topics like "machine ...
user avatar
  • 20.7k
1 vote
Accepted

C data types and format specifiers

INT02-C. Understand integer conversion rules Conversions can occur explicitly as the result of a cast or implicitly as required by an operation. Although conversions are generally required ...
user avatar
1 vote

C data types and format specifiers

Looks like C is (internally) casting the constant 2 (or probably more correctly, the result of n - 2) as an int since that is the essential difference between the two printfs. You might search the ...
user avatar
1 vote
Accepted

Conceptualising resizing in pset5

To answer your question: What I don't understand is, when it comes to i = 1, how is it that the fread function in the second for loop does not again start at the beginning of the first but of ...
user avatar
  • 1,317
1 vote

CS50 FAQ's and answers

Check50 and other server related issues Issues with the check50 command were really well answered by a dear friend, Cygni_61, you can see the common debugging methods here: Luigi Morelli's answer

Only top scored, non community-wiki answers of a minimum length are eligible