New answers tagged

-1

I think the error in your code should be in how you are calculating the average of letters and sentences per word: float averageWords = sentences / words * 100 and float averageLetters = numberOfCharacters / words * 100;. You should actually multiply letters and sentences by 100 in each formula and then divide by words.


0

I found this example, really cool. The function has been converted to a pointer. int * onefunction() { static int returnA[2]; returnA[0] = 1; returnA[1] = 2; return returnA; } void main() { int *callfunc; int a, b; callfunc = onefunction(); a = callfunc[0]; b = ...


0

You can't return an array in C. You end up returning the address of the local array, which then gets assigned to your myReturn variable.


1

This (JpegBlocks[0] = 255) uses the set operator, not the comparison operator. This allocation char StrFileHolder[7]; won't accomodate the null terminator when sprintf creates the string.


0

int sepiaRed = round((0.393 * image[h][w].rgbtRed) + (0.769 * image[h][w].rgbtGreen) + (0.189 * image[h][w].rgbtBlue)); int sepiaGreen = round((0.349 * image[h][w].rgbtRed) + (0.686 * image[h][w].rgbtGreen) + (0.168 * image[h][w].rgbtBlue)); int sepiaBlue = round((0.272 * image[h][w].rgbtRed) + (0.534 * image[h][w].rgbtGreen) + (0.131 * image[h][w].rgbtBlue))...


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 ...


0

My understanding is that list is a pointer variable initialised without a value No. It's initialized to NULL. That's what the = NULL part does. A variable can't be initialized without a value. Initializing means assigning a value. Uninitialized meaning memory is allocated, but you didn't write anything to it. Maybe this is what you meant, a pointer being ...


Top 50 recent answers are included