New answers tagged

0

In the load() function, when you're opening the file, I don't think it's valid syntax to write FILE * dictfile = open... You should write either FILE* dictfile or FILE *dictfile. Also in the load() function, when you're creating a node, you've written node*n= ... which should be invalid syntax. Write either node* n or node *n. I think you could have found ...


0

Try to log in with your GitHub account https://certificates.cs50.io/


0

Accidentally left a space in the printf function after the candidate name


1

One fundamental issue you'll face is that a credit card number is too long for an int; try using get_long() instead. I would recommend starting over with your implementation of Luhn's algorithm. Something that may help: you can get the last digit of a number by using modulo 10 (% 10) and drop the last digit with integer division by 10 (/ 10).


0

"Ready, Fire, Aim" Look at this code and think carefully about what it does and in what order: outfile = fopen(filename,"w"); sprintf(filename, "%03i.jpg", jpgCount); It opens the output file in the first line, and then builds the filename to be used to open the file. That means that the first file created and ...


0

The problem is you`re first locking all the pairs. Take a look at this example: 0 0 1 1 1 0 0 1 0 (1) 0 1 0 0 0 0 In order to have no cycles the marked truth should not be considered but you already put that truth there when you locked all the pairs so now you can't see the free column because it`s not free anymore. And at the end: if num of ...


0

Probably because ciphertext was declared but no space was ever allocated to it. It wasn't declared with a length, as in string ciphertext[5]; Programming note: By declaring variables before main, they are created as global variables. This is a very bad practice. Globals should only be declared when there is a very good reason for having them. Globals are ...


0

Close, but no. The var file_name is a pointer that is set to null. No space is ever allocated to it using malloc. When the sprintf command tries to write the filename into it, it generates a seg fault. There are two fixes here. You can malloc space to filename, or you can create a non-pointer string (char array) of sufficient length to hold the file names. ...


-1

YES! ok so the nested for loop of _x _y was wrong it should be for (int _y = -1; _y <= 1; _y++) my logic in < should have been <= Shout out to Blauelf for pointing that out! (in Discord)


1

Have a close look at the conditionals for your inner for loops. Is < 1 the right test?


1

Perhaps its because table[] is being reinitialized with every word processed in the while loop? This will result in only the last word's index pointer being left in the array. The table[] array needs to be initialized once. It should be done before the while loop starts, not inside the while loop. As for the seg fault, well, that may be related to something ...


1

The problem is that you are decreasing the width. Instead of using width - 1, use width - j - 1. Eliminate the width--; line at the end of the inner loop. Also, instead of using j<width use j<(width/2). Hope this helps. If it does then please check the tickmark.


0

You declare the variable counter outside of the loop, so it will retain its value and continuously increment over time. The top left pixel at (0, 0) will have 3 neighbouring pixels, then next pixel at (0, 1) will have 5 neighbouring pixels. Consequently, counter will go from 3, to 8, and then scale beyond any of your test conditions that might print a result....


1

It's running but nothing "matches" (ie is true) because of the date formats. Assuming "due_date" is TEXT in the db with the format "YYYY-MM-DD", current_date needs to be in the same format. That can be accomplished by changing this current_date=timestamp.date() to this current_date=str(timestamp.date()). That will coerce the ...


0

You have a problem with is_tie, your check value gets overwritten each time the loop goes. You should just return false when you know it isn't a tie and at the end return true if it it didn't end all ready .


0

fseek(inptr, -512, SEEK_CUR); But why do you want to do this? There's no need in this program to manually move the pointer. What are you trying to do? When you've read the 512 bytes into the header, they're available to both check for a signature and to write to the output file.


1

The problems are in unload. There are two issues to deal with. I'll point you at them and let you figure out how to resolve them. ;-) First, the while loop is based on the value in table[j]. The node pointed to by table[j] will get freed in the first pass through the loop. That leaves an invalid address in table[j]. I'm not sure why the loop is ...


1

With regards to your first question, fgetc technically returns an int. While it expects to read a byte of data represented as an unsigned char, it will return a negative number (usually -1, and represented by the EOF constant) when at the end of file. Assigning the result of fgetc to an unsigned char is fine (the result will be implicitly typecast) but you ...


1

Think about what this code does: while ((ch = fgetc(file)) != EOF) { fread(buffer, sizeof(BYTE), 1, file); First, fgetc reads a single char from the input file. Then the fread reads 1 byte. That first read is moving the starting point for the read into buffer. This means that no signature will ever be found. But since the fread is only ...


Top 50 recent answers are included