I am pretty new to programming and this is a college assignment. I don't know what is causing this segmentation fault, please help.
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
main() {
int i, n;
struct obat {
char nama[10];
char kode[10];
int harga[10];
int stok[10];
};
struct obat o;
printf("Masukan jumlah obat = ");
scanf("%d", &n);
for (i = 0; i < n; i++) {
printf("Masukan nama obat ke-%d", i + 1);
scanf("%s", &o.nama[i]);
}
for (i = 0; i < n; i++) {
printf("Nama obat ke-%d = %s", i + 1, o.nama[i]);
}
}