int main()
 {
    FILE *dp;
    char name[15];
    char sname[15];
    int no;
    char department[10];
    char sex[3];
    char city[15];
    int age;
    int phone; 
    int num; 
    dp=fopen("veri.dat","r");
    if(dp==NULL)          
    {
       printf("file couldnt opened\n");
       return 1;
    }   
    printf("enter student number:\n");
    scanf("%d",&num);


    while(!feof(dp))
    {
        fscanf(dp,"%d",&no);            
        if(no==num)
        {   
            printf("%s%s%d%s%s%s%d%d",name,sname,no,department,sex,city,age,phone);

        }   
    }
    fclose(dp);
    system("pause");
    return 0;
}  

I am new in c. Can you help with my codes?

Yes, IF we knew what you needed hwlp with.
1) Use CODE tags around all the code
2) A complete explanation of what you are trying to do and what actually happened is necessary.

We were trying to get info about a student from a .dat file we created before. But when i try to compile my
codes it stopped working.

What does that mean? How can your code stop working when you compile it?

judging from the code you posted most of the variables have no value yet your trying to print them?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.