Questions tagged [general]
The general tag has no usage guidance.
9
questions
0
votes
1
answer
16
views
How does continue; differ from break; in a loop
If i understand correctly, continue skips all the lines of the loops current iteration and starts again from the top whereas break exits the loop. Is this correct?
0
votes
0
answers
10
views
General coding question about reading code
I feel like I am doing ok at understanding the logic of my code while I'm sitting down writing it. However, once I am done writing upon revisiting the code I find it hard to understand again and ...
0
votes
2
answers
593
views
PHP removal from CS50
Hello dear CS50 folks,
I was wondering - just out of curiosity - why PHP was removed from CS50 ? And why choose Python instead ?
If someone could give me an elaborate answer, explaining the ...
0
votes
2
answers
162
views
C data types and format specifiers
I was playing around with data types and format specifiers. Compiling the first snippet of code gives no errors but when I try to use unsigned shorts (or shorts in general) I get an error on line 12: ...
2
votes
2
answers
1k
views
What will realloc() do if the contiguous memory location is already occupied?
Consider-
char* name1 = malloc(4 * sizeof(char));
name1 = "Mike";
Now if i want to put "Mike Smith" in the same string "name1", I need 6 more bytes of memory (one for the space and 5 for "Smith". ...
1
vote
1
answer
3k
views
When we free a dynamically allocated memory, what happens to the pointer pointing at it?
After watching section on "Dynamically allocated memory" (from Week 4) several times, I still have a question unanswered.
Consider the following code-
// Allocates 4 bytes of memory on heap and ...
1
vote
1
answer
738
views
Memory allocation: recommended practices
I'm rambling a little with hacker 2 (the passwords') and, in the meantime, gained some insight about pointers, mem-alloc, 'valgrind', etc... It's been a truly great, challenging experience.
But, ...
0
votes
1
answer
212
views
Conceptualising resizing in pset5
I've just solved the resizing part of pset5 without completely understanding what is happening during the reading of the infile and writing of the outfile bit. To clarify my question, here is my code ...
1
vote
3
answers
187
views
CS50 FAQ's and answers [closed]
I've created this post so that all the FAQ's and their answers can be collected here, in order to prevent re answering the same questions over and over again, be sure to check the answers to this ...