Reputation: 15
I'm trying to get the contents from the file yh.dat which HAS the text like "456 78921" and somthing else by C.But when I try debug the code,the FILE pointer isn't NULL(0x00428af8) and the _ptr and the _base is NULL(0x000000).They says "CXX0030:Error:expression cannot be evaluated".How to solve it?
int main(){
FILE *fp=NULL;
fp=fopen("yh.dat","rb");
if(fp==NULL)
{
printf("error");
exit(0);
}
return 0;
}
Upvotes: 0
Views: 659
Reputation: 490663
To allow you to change the file buffering, C doesn't set up the buffer for a file until you issue the first read. As such, until you attempt at least one read, it's normal for the members of whatever struct the FILE * points at to be in an only semi-initialized state.
Have you tried just reading data to see if it works?
Upvotes: 2