我有以下代碼:爲什麼程序有時會「跳過」printfs?
if (!strcmp(ent_child->d_name, "eeprom")){
printf("\tread_from_driver: found a match! ");//DEBUG
get_child_path(child_path, child_path, "eeprom");
printf("The path is: %s\n", child_path);//DEBUG
read_eeprom(child_path);
}
這將導致在某些時候段錯誤,(大概get_child_path),但第一個printf不會發生,即使當我修改代碼是這樣的:
if (!strcmp(ent_child->d_name, "eeprom")){
while(1)
printf("\tread_from_driver: found a match! ");//DEBUG
get_child_path(child_path, child_path, "eeprom");
printf("The path is: %s\n", child_path);//DEBUG
read_eeprom(child_path);
}
它確實發生。這是怎麼回事?這絕對不是我第一次觀察到這種行爲。
也許嘗試刷新輸出? – quasiverse