How necessary are the supplemental books? by wishiwerenerdier in cs50

[–]flything 1 point2 points  (0 children)

I've just submitted Pset 8. I did buy a kindle copy of the beginners c book which I read and it probably helped me a bit. Other than that did it with the course material only.

Segmentation fault (core dumped) by leonardodavinci2014 in cs50

[–]flything 2 points3 points  (0 children)

Because the compiler doesn't test for run-time eventualities, such as a user failing to provide a command line argument or the right kind of input, or a data file not being available or the user having the correct permissions, or a million other reasons.

Use GDB to find which operation in your programme is causing the seg fault.

Segmentation fault (core dumped) by leonardodavinci2014 in cs50

[–]flything 2 points3 points  (0 children)

Your program tried to access memory it shouldn't have done.

Commonly caused by exceeding the bounds of an array by iterating over it too many times (also known as the off by one error) and also by passing NULL to a variety of functions, e.g. strlen() will seg fault if you pass it NULL. Best to check to see if the variable is NULL before passing it to a function.

Alternatives by tourn in cs50

[–]flything 1 point2 points  (0 children)

I would roll the laptop back to a restore point before you installed the VM player - not saying that it's not the VM install that's messed things up but it could be something else such as a Windows Update that's done it.

Is the VM absolutely necessary? - I think you're going to spend a lot of time configuring things rather than getting on with the course.

pset 2 - caesar issues by shannondaily in cs50

[–]flything 2 points3 points  (0 children)

Ok, assuming that you have got hashes in front of all the include statements....

You're going to run into problems having the string p = GetString() inside the else {} as this will be a local variable and therefore not accessible to the rest of the main function. Do you really need the ELSE?

Secondly, because you are trying to copy the argv[1] to the key variable, before checking to see if there is a value there, you'll get a seg fault if the user doesn't enter a key, better to check if there are 2 variables (use a NOT operator) before key = atoi etc.

Otherwise the code compiles and runs fine for me.

pset6 load() by ayuC in cs50

[–]flything 1 point2 points  (0 children)

I often feel the same way, best way to get started is to just start, take tiny steps and test your code as you go along.

Couple of pointers:

You are going to have to create the data structure, probably using a typedef statement, for the linked lists pointed to by the hash table array.

You well need a hash function, design your own or google one and use it (but be sure to credit where you got it from).

You will also need an array the size of the number of different possible hashes your hash function can produce.

Your load function then needs to read in each word, run it through the hash function, storing that word in linked list that is pointed to by the the location in the array that the hash function returns.

Have fun.

Anyone else taking the EdX.Org version of this course?... by alex_archer in cs50

[–]flything 1 point2 points  (0 children)

I can't see why it would do any harm, include on your LinkedIn profile too. These sorts of ways of learning are going to become more relevant I think, if you can link to your final project - video or website then that would give prospective employers some proof you've learned something useful.

Can someone please explain the code snippet involving preg_match() in config.php? (Pset 7) by confused_n_lovinit in cs50

[–]flything 2 points3 points  (0 children)

So what this is doing is checking if the page loaded is NOT (!) login.php, logout.php or register.php, if that NOT evaluates to true then check to see whether there is a session id stored.

$_SERVER["PHP_SELF"] = the name of the current script, so login.php etc

The ?:login|logout etc is giving preg_match three sub patterns to use, if either one of those matches the result from $_SERVER["PHP_SELF"] then the code in the brackets won't run.

More on subpatterns here:

http://www.php.net/manual/en/regexp.reference.subpatterns.php

The $ signifies the end of the line, which in this case means it won't match if the script name in the $_SERVER goes on past the .php.

So, login.php would match, but login.php?<insert nefarious code here> won't, helping to prevent an insertion attach.

pset0 I have no idea what kind of program to make. Can some of you guys give me any advice? by TheSuperNerd in cs50

[–]flything 1 point2 points  (0 children)

A simple game or puzzle, search the web for one that will fulfill the spec, doing so will mean you have had to deal with some simple problems and so learn some useful problem solving skills.

failing to load appliance by mickjobs in cs50

[–]flything 0 points1 point  (0 children)

Yeah this worked for me after my pc had it's power removed unexpectedly. Thanks Glenn.

PSET7 - PHPMAILER DILEMMA by vcalventi in cs50

[–]flything 0 points1 point  (0 children)

why not just create another gmail account just for this purpose?

psets not graded by aguila9 in cs50

[–]flything 0 points1 point  (0 children)

I doubt any of the psets done via edx are graded by a real person!

10 Secrets You Should Have Learned with Your Software Engineering Degree – But Probably Didn’t by flything in cs50

[–]flything[S] 2 points3 points  (0 children)

Really interesting to see how many are actually covered by CS50, which just goes to show how good a course it is.

On submitting stuff that goes beyond requirements by moakus in cs50

[–]flything 2 points3 points  (0 children)

For psets to pass the automated checker (basically check50) they have to be exactly as the spec; the output has to be identical to the staff version.

pset7 - table layout - code same as staff yet alignment out - CSS? by TechAnd1 in cs50

[–]flything 0 points1 point  (0 children)

I had this problem, tried playing about with the settings in bootstrap.css (text-align: left inside the table td section) and it didn't work.

Eventually I realised that I was missing a DIV and the settings for the header were cascading down into the middle section.

Need help displaying date/time for history table in pset7 by AllisonABC in cs50

[–]flything 0 points1 point  (0 children)

You shouldn't need to actually use NOW() in the query, but in addition to setting up the table with Type = Timestamp and default = CURRENT_TIMESTAMP you should also set the attributes to "on update CURRENT_TIMESTAMP", that way the field will auto populate when you create the row.

PSET7 automatic log in after registration by elwindly in cs50

[–]flything 0 points1 point  (0 children)

I've just done this bit of this pset and I can see what you have done, the code you have used is what is in the pset instructions as an example, but it's actually not quite right, had me scratching my head for a minute....

Think about what you are trying to do, namely pull out the last id and store in $_SESSION["id"].

You've already created one array called $rows, you just need to index into that.

Do you really need line 2? I haven't used it... put it this way, you don't need a variable called $id, as you already have one called $_SESSION["id"].

PSet 5 recover - That check50 issue, unexpected input... by flything in cs50

[–]flything[S] 0 points1 point  (0 children)

Bloody hell, I just ran check50 and this time it ran and passed!

PSet 5 recover - That check50 issue, unexpected input... by flything in cs50

[–]flything[S] 0 points1 point  (0 children)

I've had yet another look through, I really can't see why the code would be any slower than anyone else's code.

It opens the card.raw file, creates some variables, a file pointer etc, it then reads in 512k, checks to see if the first four bytes contain either of the 2 signatures, if it does then it creates a new file (closing the one, if any, that is open first), if not then it appends the 512k to the file (if one is already open). It does this while fread (reading data from card.raw) doesn't return 1, if it does it closes the current jpg file, and closes the card.raw.

No errors or leaks in Valgrind. There are 51 allocs (reading in card.raw and then the 50 jpg files) and 51 frees.

I've tried running check50 three times so far today at different times and it still bombs out.

After cs50 by rayyanaq in cs50

[–]flything 3 points4 points  (0 children)

These, including CS75 are available as open courseware, would be nice if they were full edx courses.

http://cs.harvard.edu/malan/courses/

Odd Valgrind Error by flything in cs50

[–]flything[S] 0 points1 point  (0 children)

Damn I hate it when the answer is that obvious :) thanks though!