Passing of values from text file to array

后端 未结 2 877
离开以前
离开以前 2021-01-28 01:44

I\'m having some problems with my code.

My program calculates the amount of resistance based on the color of the three bands coming from an input file, then printing

2条回答
  •  梦毁少年i
    2021-01-28 02:15

    When you use

    token = strtok(color, ",");
    

    you only split on "," but on the file you have also a space after it so it should probably be

    token = strtok(color, ", ");
    

    or remove the spaces from the file

    Also for the kilo-ohms i think you forgot a /1000 in the print

    if(resistance > 1000){
      fprintf(fptrout,"Resistance in Kilo-Ohms: %f",resistance/1000);
    }
    

提交回复
热议问题