zsh: bus error when passing struct to thread

I am running into the error above trying to pass a file pointer in a struct to a thread. It is an assignment requirement to have the thread be passed this output file to write to. //struct to pass file to thread 2 struct THEAD_TWO_DATA{ FILE *outputFile; }; void* ThreadTwo(void *received_struct){ struct THEAD_TWO_DATA *struct_ptr =… Read More zsh: bus error when passing struct to thread

Misalignment of assigning the first element in void* arrays and malloc assigning more memory than necessary

I’m confused as to why the following code still runs even though i have not allocated enough memory for the void* arr[]; i’m still able to write to those locations and not run into a segfault. void** arr; arr = realloc(NULL, 1); // 1 Byte allocated arr[0] = (void *)1; // able to store a… Read More Misalignment of assigning the first element in void* arrays and malloc assigning more memory than necessary

Segfault when I loop through the array of a dynamically allocated structure

Here’s the problem, I’m trying to allocate a struct containing an array of pixels but it gives me a segfault and I can’t find the error, here’s how I originally tried to do it: #include <stdio.h> #include <stdlib.h> #include <stdint.h> typedef struct { int len; uint16_t tex_w; uint16_t tex_h; uint32_t** tex; } Tex_Array; int main(void)… Read More Segfault when I loop through the array of a dynamically allocated structure

How to detect a alphabet if its a vowel or not with C? Here is my programme

How to detect a alphabet if its a vowel or not with C? Here is my programme #include <stdio.h> #include <ctype.h> #include <stdbool.h> int main(){ char input; scanf("%c", &input); if(isupper(input)){ printf("it’s capital letter.\n");} else{ printf("it’s small letter.\n");} int C = ((int)input); //Change C from a char to sacii code int intarray[10] = {65, 69, 73,… Read More How to detect a alphabet if its a vowel or not with C? Here is my programme

Not printing grades as a 2d array

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> void getGrades(FILE *ifp, int assigns, int stus, int grades[assigns][stus]); void printGrades(int assigns, int stus, int grades[assigns][stus]); int main(int argc, char *argv[]) { int assigns = 0; int stus = 0; int grades[assigns][stus]; // command line arg. error checking if (argc != 2) { printf("Syntax Error: ./<exec> <file>\n");… Read More Not printing grades as a 2d array

What is wrong with the following C code for Bisection method, it doesn't show the actual root, but instead 0.000000. (I'm a beginner)

For some reason, I’m not sure what, it isn’t showing the approx root, the avg which should be printed as a non-zero floating point is rather giving 0 as it’s value at the end, I’m also not sure if fabs is necessary here or not. Please help me out, p.s- my first question here. //… Read More What is wrong with the following C code for Bisection method, it doesn't show the actual root, but instead 0.000000. (I'm a beginner)