Hot answers tagged

8

I think this is typical specially if this is your first CS/programming course. Thinking: You should probably consider these points: you, as a human being, should be able to solve the problem yourself or at least you should have a basic idea of a solution before you try to make the computer solve it. I think problems that can be easily solved by human ...


4

The Honor Code requires that you don't post any solution code publicly, so it should be fine if your git is private.


4

The output does not match the spec. This plaintext : should be this plaintext:. The same with ciphertext:. There is no space between the word and the :. While this may seem "overly strict", it is good practice for when you write code for a boss or a customer and there is real money on the line.


3

I found why grade were 0 in PSET2 ,it was all my mistake. Programs were correct, but the problem was i didn't have the CS50 appliance. So i didn't check the programs with checkCS50. I thought programs will be checked by humans. But it seems they are feeding it to checkCS50 and on results they are giving grades. So like i missed printing an '\n' at end of ...


3

On which version of the workspace are you? The current version as of 2017-11-13 is v125. If update50 doesn't end in an error message, you probably are at that version. Also, how do you compile? The default of make hello would use environment variable LDLIBS with content -lcrypt -lcs50 -lm. Here the -lcs50 is relevant, it tells the linker (which is invoked ...


3

Hmmm.... Good question for new programmers! The style guide is right, more than 2 or 3 nested for loops should raise red flags, especially if they are based on the same controlling variable as in the example from the image (from the style guide). The important thing here is to realize that there's a difference of asking whether it should be done vs. it ...


2

If you are doing this course via edX, you must submit the Standard editions. The Hacker editions are only for your own extra learning.


2

When you registered for edx with your Google account, you must have specified a password. The form requires it. Use that password and your username, and it should work. If you forgot your username, it is the top right corner of any edx page you are logged in to. If you forgot your password, click the small down arrow beside your username in the top right ...


2

It's interesting that you get 50 files, but something is amiss. Look at your test for signatures: if (buffer[0] == 0xff && buffer[1] == 0xd8 && buffer[2] == 0xff && buffer[3] <= 0xe0 && buffer[3] >= 0xe0) The problem revolves around the testing of buffer[3]. You are checking that it is both <= and >= 0xe0, meaning ...


2

Are you sure you are in the correct link and that you are signed in? Try this: https://courses.edx.org/courses/HarvardX/CS50x3/2015/courseware/. I can see all of the weeks and the psets.


2

Hmmm..... char method_checker[4]; method_checker[4]= '\0'; You are setting '\0' one element beyond the end of method_checker[]. This is also probably leaving garbage data at method_checker[3] before you do the compare. Remember, the index starts at 0, not 1, so method_checker[] has elements 0, 1, 2 and 3 only. If this answers your question, please click ...


2

I think the problem is because, when inserting, you're checking and/or allocating memory for cursor->children[c - 'a']. Now if c is an uppercase char, that's a problem. Update: I don't really know how I couldn't see that before, but it happens. You're skipping chars when using fgetc in the condition of the do while loop. Also, you're not checking for the ...


2

You need to round the result of change * 100. You can do that simply with the round function found in math.h. For example, round(4.2*100) would return 420, where 4.2*100 gives 419.


2

The problem lies here: if(isdigit(argv[1][i] != true) You need to fully understand how isdigit() works, specifically the return value, and the numeric value of true. The is() family of functions all return an int. When true, each will return a different number that is a power of 2. This goes back to the history of programming and register values used in ...


2

The program is supposed to take the filename of the input file as a parameter. BUT, you've hardcoded it into the program. So, when check50 tests to see if the program terminates when there's no input parameter, it fails. If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)


2

It's failing because the code isn't handling invalid keys correctly. For the cases where the key contains a number or a duplicate letter, the program should terminate. Check50 is timing out because the code is waiting for user input that check50 isn't giving. The problem lies here: for (int i = 0; i < argc; i++) It looks like you don't have an ...


1

You can look up the problem sets (not the solutions, but the actual instructions) on Google. For example, looking up Problem Set 1 C CS50 has the problem set link as the first result, which you can click on to see the instructions, walkthroughs, etc. If you still have issues/comments, please comment below. :-)


1

First to the error: i<len,k>=0 uses the comma operator, which evaluates its left side, discards the result, and evaluates to its right side. So i<len,k>=0 is the same as k>=0, the value of i<len is ignored. You're doing Caesar's cipher, right? This one looks like a strange crossover of caesar and vigenère. In Caesar's cipher, you shift ...


1

So, where do you set the contents of old_bi? Tip: get everything working for n=1 - first the header and then the image. Then do n=2, get the header right and then the image. ;-) If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)


1

If by this recommended syntax for adding a column using SQLite does not appear to work. you mean foreign key is not enforced, check out section 2 in SQLite doc, which says Assuming the library is compiled with foreign key constraints enabled, it must still be enabled by the application at runtime, using the PRAGMA foreign_keys command. For example: sqlite&...


1

There's a problem in this routine: else if (found_jpeg) { printf("Writing to existing JPEG...\n"); sprintf(fn, "%03i.jpg", jpegs); FILE *img = fopen(fn, "w"); fwrite(&buffer, sizeof(BYTE), 512, img); printf("Succesfully wrote to %s\n", fn); } Your intention is to "[write] to existing JPEG....". That's not ...


1

The GetFloat() function takes no input, so you should not perform arithmetic on it as that results in errors like the one you are seeing. If you want to output the converted value as a float, you must declare a float -- which you are already doing in float tempf -- then you should then convert it to fahrenheit by assigning it the expression that converts ...


1

You have made a mistake that is very frequent among novice programmers, you check for the returned bool using ==. You should instead use something like: if (islower(text[i])) { // do things... } The reason your code produces no output, is the fact that islower() doesn't return a bool, but an int. Behind the scenes, true == 1 and false == 0, but ...


1

According to MSDN biSizeImage The size, in bytes, of the image. This may be set to zero for BI_RGB bitmaps. If biCompression is BI_JPEG or BI_PNG, biSizeImage indicates the size of the JPEG or PNG image buffer, respectively. Let's say you have an image with 3x3 pixels, and you want to enlarge it by a factor of 2. So your new biWidth == 6 and biHeight == 6. ...


1

First - think about what a segmentation fault is. It happens when you try to access memory that doesn't belong to you. https://stackoverflow.com/questions/2346806/what-is-a-segmentation-fault Try to plug in some sample numbers into this equation. Here's a hint - try to start with a min of 0 and a max of 10 and see if your mid always stays between 0 and 10....


1

Admittedly I don't fully grasp what you mean "merge several psets". However,in the narrow and specific context of CS50 pset7 & pset8, you do not need two databases. Consider adding the places table to the pset7 database. You wouldn't have to change any config files or functions. (You'd have to modify pset8.sql for database name change). Adding the "...


1

Yes they will. The grading will be done according to your last submission. I have submitted more than one solutions for half of the psets. Got the grades according to the last submission.


1

You have created an infinite loop through the improper use of the decrement operators. Look at the following: // switch numbers 2 and 1 board[j][i--] = 2; board[j--][i - 2] = 1; Both i and j control the inner and outer loops and are incremented on each pass of their respective loops. In these two operations, the code is ...


1

It looks as though you don't have a full understanding of how directory structure works. Looking at the image that you posted, you have already created the subdirectory pset1 in the directory ~/workspace. If you look at the command line prompt, it says clairefasstner:~/workspace/pset1. That prompt gives the username before the colon and everything after the ...


1

fixed apparently the problem was in how I was using strcmp to detect differences


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