When I run the following code, I get an error.
void printData(int total_trees,int burned){
printf("Before printing data\n");
float percentBurned = (float)burned / (total_trees+burned)*100;
printf("total burned: %d (%.1f\%)\n",burned,percentBurned);
printf("trees left: %d\n", total_trees);
// printf("trees left: %d\n", total_trees);
printf("After printing data");
}
The error says *** stack smashing detected ***: terminated
Before outputting the error, it outputs the first three printf statements.
Link to image because this is my first stackoverflow post
I've tried rearranging everything so many times and nothing has worked so far. I'm guessing the printf statements themselves aren't triggering an overflow, but I could be wrong.
I'm grateful for any help you can give :)
edit: printf("trees left: %d\n", total_trees); is the last line that runs before throwing the error