I have written very simple code, that I used to feel confident in but it isn't working. I don't know if I am doing anything wrong or perhaps it is something wrong with my vscode. I have allocated memory for an array of integers and chars, and I then use scanf to read values that I then want to save in said arrays. But it appears it is saving the values as garbage value when I use printfs to debug.
For context: tamanhos = sizes, which are supposed to be either p, P, g or G, and quantidades are supposed to be integers.
#include <stdio.h>
#include <stdlib.h>
#define professores 7
int main () {
int quantidade, total, holder;
char tamanho;
total = 0;
int * quantidades = (int*)malloc(professores*sizeof(int));
char * tamanhos = (char*)malloc(professores*sizeof(char));
for (int i = 0; i < 7; i++){
scanf(" %d", &quantidade);
scanf(" %c", &tamanho);
quantidades[i] = quantidade;
tamanhos[i] = tamanho;
}
printf("%d", total);
for (int i = 0; i < 7; i++ ){
if (tamanhos[i] == "P" || tamanhos[i] == "p") {
holder = quantidades[i];
total = total + quantidades[i]*10;
}
else if (tamanhos[i] == "G" || tamanhos[i] == "g") {
total = total + quantidades[i]*16;
}
}
printf("%d\n", total);
int xprof = total / 7;
printf("%d", xprof);
free(quantidades);
free(tamanhos);
return 0;
}