0
 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?

Edited by deceptikon: Fixed code blocks

3
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by zeroliken
0

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.

0

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.

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.