Whats wrong with fread in this program?

后端 未结 3 1657
-上瘾入骨i
-上瘾入骨i 2021-01-25 12:05

I\'m intermediate student of C. I\'m trying to make a bank management program but first I need to make a login program, so I created one of the following. As I\'ve recently lear

3条回答
  •  伪装坚强ぢ
    2021-01-25 12:36

    The problem is that you have an ASCII/text file but you are trying to use fread to read directly into a structure; this requires a binary formatted file. fread cannot do format conversion. Use fscanf instead:

    fscanf(fp, "%s %d", &log_in.u_name, &log_in.u_pin);
    

提交回复
热议问题