help me! What wrong with my code?

I'm amateur in C program! please help me! thanks!
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 40
struct Diachi{
    int quan;
    char phuong[30];
    unsigned to;
};
struct Canbo{
    char hoten[30];
    int tuoi;
    float luong;
    Diachi diachi;
};
void nhap(Canbo cb[MAX],int n){
    char tmp[10];
     for(int i=0;i<n;i++)
    {
        printf("    Can bo thu: %d",i+1);
        gets(tmp);
        i=atof(tmp);
        printf("\n      Ho va ten: ");
        gets(cb[i].hoten);
        printf("        Tuoi:");
        gets(tmp);
        cb[i].tuoi=atof(tmp);
        printf("        Quan:");
        gets(tmp);
        cb[i].diachi.quan=atof(tmp);
        printf("        Phuong:");
        gets(cb[i].diachi.phuong);
        printf("        To:");
        gets(tmp);
        cb[i].diachi.to=atof(tmp);
        printf("        Luong:");
        gets(tmp);
        cb[i].luong=atof(tmp);
    }
}
void tim(Canbo cb[],int n){
    for(int i=0;i<n;i++)
        {if((cb[i].diachi.quan==3)&&(cb[i].luong>5000000))
        {
            printf("Hoten: %s\n",cb[i].hoten);
            printf("Tuoi: %d\n",cb[i].tuoi);
            printf(":Luong: %f\n",cb[i].luong);
            printf("Dia chi: To: %d, Phuong: %s, Quan: %d\n",cb[i].diachi.to,cb[i].diachi.phuong,cb[i].diachi.quan);
        }}
}
main(){
    Canbo cb[MAX];
    int i,n;
    char tmp[10];
    printf("Nhap vao so can bo: ");
    gets(tmp);
    n=atof(tmp);
    nhap(cb,n);
    printf("Nhan vien can tim la:");
    tim(cb,n);
getch();
}

State the problem - both what you want it to do and what it does. Also, the tags are [code], not [output].
Topic archived. No new replies allowed.