int fh = -1;
fh = open("/persist/xxxxx/yyyyyy", O_RDONLY);
char buff[2]="0";
if(fh != -1){
read(fh, buff, 1);
}
strcmp(buff, "2") == 0;
#最后一定要,否则循环进入fh的值持续增长而超出int范围。
close(fh);
另一种方法:FILE
FILE *fl;
fl = fopen("/persist/xxxxx/yyyyyy", "r");
char buff1[2]="0";
if(fl != NULL){
fread(buff1, sizeof(buff1), 1, fl);
}
int identifyingValue = atoi(buff1);
identifyingValue == 2;
fclose(fl);