New answers tagged

0

var correct = document.querySelector('.correct'); correct.addEventListener('click', function () { // I had misspelled Listener correct.style.backgroundColor = 'green'; document.querySelector('#feed1').innerHTML = 'Correct!'; // It should have been #feed1 });


0

The problems lie here: scanf("%d", &c); for ( i = 0; i <= c ; i++) { digits[c-i] = num % 10; num = num /10; scanf("%d", &digits[c-i]); } The scanf() function calls for user input. The call to get_long_long() in your credit() function gets all the needed user input. There is no need for any additional ...


0

for (int x = 0; x < width; x++) // <- width ?? { for (int y = 0; y < width; y++) { image[x][y].rgbtRed = round(buffer[x][y].rgbtRed); image[x][y].rgbtGreen = round(buffer[x][y].rgbtGreen); image[x][y].rgbtBlue = round(buffer[x][y].rgbtBlue); } } Surely you meant to write height at ...


0

Dividing an integer by an integer does not always give the expected answer. To a computer 24/5 is 4. Consider this hint: "The values of a pixel’s rgbtRed, rgbtGreen, and rgbtBlue components are all integers, so be sure to round any floating-point numbers to the nearest integer when assigning them to a pixel value!"


1

You seem to be confused about malloc(). malloc allocates memory from heap. You can store anything inside this allotted memory location. Specifically it expects the following input: number of bytes of memory you want to be allocated. int *ptr; ptr = malloc(sizeof(int)); *ptr = 300; printf("Address of ptr: %p\n", ptr); printf("Value inside ptr: %...


1

char *flname = "0.jpg"; The string here is immutable. Writing to it again is undefined behavior. You need to stack allocate space for a file name. 000.jpg is 7 characters and you need one extra byte to store the null terminator so 8 characters will do it. char flname[8]; You almost had it. In essence, I'm not sure what I could use to close the ...


1

You probably ran into the (now resolved) Auth problem described here: https://cs50.statuspage.io/incidents/gwmwslhlmszx Can you try again? It should work now.


1

The valgrind tool is helpful in this case. Adding the necessary functions to a file with your implementation, it points to line 104: ==72356== Conditional jump or move depends on uninitialised value(s) ==72356== at 0x4A3EF5D: _IO_file_overflow@@GLIBC_2.2.5 (fileops.c:783) ==72356== by 0x4A27A6D: __vfprintf_internal (vfprintf-internal.c:1688) ==72356== ...


Top 50 recent answers are included