Bantu saya selesaikan program ini,.

Program udah jalan cuma dibagian searchnya eror,.mohon berikan solusi..
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
char pilih, pil;
int i, x, b, c, j, k, cari, edit, hapus,false,true,found, index[10];


int main(){
struct data{
int NIM;
char nama[20];
}mahasiswa[5];
void add(void);

do{
clrscr();
printf("\n          MENU");
printf("\n======================");
printf("\n 1. Insert");
printf("\n 2. Search");
printf("\n 3. Edit");
printf("\n 4. Delete");
printf("\n 5. Exit");
printf("\n======================");
printf("\nPilihan anda : ");
pil=getche();

switch(pil){
case '1':

clrscr();
printf("\n\n\n");
printf(" Menu Masukkan Data");
printf("\n====================\n");
do{
printf("Data ke %d\n",i+1);
printf("Masukkan NIM  : ");
scanf("%d",&mahasiswa[i].NIM);
printf("Masukkan nama : ");
scanf("%s",&mahasiswa[i].nama);
i++;

printf("\n=======================\n");
printf("Isi data lagi? [y/t] : ");
pil=getche();
printf("\n");
}

while(pil=='Y'||pil=='y');
break;

case '2':

clrscr();
printf("\n\n\n");
printf("Menu Pencarian Data\n");
for(x=0;x<i;x++)
{
printf("\n\nData ke %d\n",x+1);
printf("NIM  : %d\n",mahasiswa[x].NIM);
}

printf("\n=========================\n");

do{
printf("\nNIM yang akan dicari : ");
scanf("%d",&cari);
i=0;
found=false;
while((i<x)&(!found))
{
if(mahasiswa[i].NIM==cari)
found=true;

else
i=i+1;
}

if(found)
{
printf("\nNIM %d ditemukan\n",cari);
printf("\n============================\n");
printf("NIM  : %d\n",mahasiswa[i].NIM);
printf("Nama : %s\n",mahasiswa[i].nama);
}

else{
printf("\nNIM %d tidak ditemukan\n",cari);
}

printf("\n============================\n");
printf("Cari lagi? [y/t] : ");
pil=getche();
}
while(pil=='Y'||pil=='y');
break;

case '3':

clrscr();
printf("\n\n\n");
printf("Menu Pengubahan Data\n");
printf("\n======================\n");
printf("Semua Data\n");
for(x=0;x<=i;x++)
{
printf("\nData ke %d\n",x+1);
printf("NIM  : %d\n",mahasiswa[x].NIM);
printf("Nama : %s\n",mahasiswa[x].nama);
}

printf("\n=======================\n");
printf("\nNIM yang akan diedit : ");
scanf("%d",&edit);
b=0;
for(j=0;j<=i;j++)
{
if(x=edit)
index[b]=j;
b++;
}

if(b>0)
{
printf("\n========================\n");
printf("NIM %d ditemukan\n",edit);
printf("Data Lama\n");
printf("NIM  : %d\n",mahasiswa[i].NIM);
printf("Nama : %s\n",mahasiswa[i].nama);
printf("\n========================\n");
printf("Masukkan Data Baru\n");
printf("NIM  : ");
scanf("%d",&mahasiswa[x].NIM);
printf("Nama : ");
scanf("%s",&mahasiswa[x].nama);
}

else{
printf("Data tidak ditemukan\n");
}

printf("\n============================\n");
printf("Data Baru\n");
printf("NIM  : %d\n",mahasiswa[x].NIM);
printf("Nama : %s\n",mahasiswa[x].nama);
break;

case '4':

clrscr();
printf("\n\n\n");
printf(" Menu Hapus Data\n");
printf("=====================\n");
printf("Semua Data\n");
for(x=0;x<i;x++)
{
printf("Data ke %d\n",x+1);
printf("NIM  : %d\n",mahasiswa[x].NIM);
printf("Nama : %s\n",mahasiswa[x].nama);
}
printf("\n===================\n");
printf("\nNIM yang akan diHapus : ");
scanf("%d",&hapus);
b=0;
for(j=0;j<=i;j++)
{
if(x=hapus)
index[c]=k;
c++;
}
if(c>0){
printf("\n=======================\n");
printf("NIM %d ditemukan\n",hapus);
}
else{
printf("\nData Tidak Ditemukan\n");
}
printf("Apakah anda yakin ingin menghapus data? [y/t] : ");
pil=getche();
if(pil=='Y'||pil=='y'){
printf("\nData Terhapus\n");
mahasiswa[x].NIM=0;
mahasiswa[x].nama[20]=0;
}
else
printf("\nData Tidak dihapus\n");
break;

case 5:
exit(0);
}
printf("\nKembali ke MENU utama? [y/t] : ");
pilih=getche();
}
while(pilih=='Y'||pilih=='y');
printf("\nAnda Keluar\n");
}

Postingan terkait:

2 Tanggapan untuk "Bantu saya selesaikan program ini,."