Let's say I have a text file
(1st line) 234,120,4521,93
(2nd line) 1, -100
(3rd line) 4, -40
(4th line)1, -49
Code:
FILE *fp=fopen(argv[1],"r");
fscanf(fp,"%d%d%d%d",&piels,&coors,&bud,&iron_city); // This is the first line of the text file (234,120,4521,93)
while(fscanf(fp,"%d%d",&brand_id,&transaction)!=EOF)
{
if(brand_id==1) // This is the second line (1, -100) where brand_id=1 and transaction=-100
// add -100+-49
}
And i want to add the values of -100 and -40 when conditions are met. How would i do that?