1

In C write a program that must accept one argument from the command line. The argument...

Question

In C write a program that must accept one argument from the command line. The argument...

In C write a program that must accept one argument from the command line. The argument is the name of the file containing the processes (for example: processes.csv).This file is comma-separated with three columns (process ID, arrival time and burst time) with each row for an individual process. You can assume that this file will have a maximum of 10 processes.

For example

Input: processes.csv

ProcessID,Arrival Time,Burst Time

0,1,3
1,0,5
2,9,8

3,10,6

Where the first element is processes, the second is Arrival time and the third is Burst time. Store each in separate arrays (one for processes, one for arrival and one for burst)

Thanks!

Answers

The code in image:

1 #includec stdio.h> 2 #include<string.h> 3 #include«ctype.h> 4 int main) lincluding pacakages FILE *fp1; char file_name[100]43 printf(process id,arrival id,burst time\n) for(i:0; İs(length/3) ;i++){ 45 46 47 48 49 50 51 //printing every number pri

The code in the text:

#include<stdio.h> //including pacakages
#include<string.h>
#include<ctype.h>
int main() {
   FILE *fp1;
   char file_name[100],c; //declaration of characters
  
   printf("Enter name of the file: ");
   scanf(" %s",file_name); //taking file name
  
   fp1=fopen(file_name,"r"); //opening the file
  
   int list[30],process_id[10],Arrival_time[10],Burst_time[10],len; //decalring list
  
   c=fgetc(fp1); //taking character from fp1 pointer or file
   int i=0,number,num=0;
   while(c!='\n'){ //iterating until it hits a newline
       c=fgetc(fp1);
   }
   c=fgetc(fp1);   
  
   while(c!=EOF){ //iterate until end of file
       if (isdigit(c)){ //if it is digit
           sscanf(&c,"%d",&number); //changing character to number (c)
           num=(num*10)+number; //if it has more than 1 digit..ex:-12== 0*10+1=1 , 1*10+2=12
       }
       else if (c==',' || c=='\n') { //if it is new line or , then it will store the number in list
           list[i]=num;
           num=0;
           i++;
       }
       c=fgetc(fp1);
   }
   int j=0,length=i+1;
  
   for(i=0;i<length;i++){ //iterating through each numbre storing it in corresponding lists
       process_id[j]=list[i]; //adding numbers into lists using indices
       Arrival_time[j]=list[i+1];
       Burst_time[j]=list[i+2];
       i=i+2;
       j++;
   }
  
   printf("process id,arrival id,burst time\n");
   for(i=0;i<(length/3);i++){   
       printf("%d, ",process_id[i]); //printing every number
       printf("%d, ",Arrival_time[i]);
       printf("%d\n",Burst_time[i]);
   }
   return 0;
}

Output:

jack@jack-TravelMate-P243-M:~$ ./a.out Enter nane of the file: processes.csv process id,arrival id,burst tine 0, 1, 3 11, θ,


Similar Solved Questions

2 answers
A cyclist bikes at a constant speed for 18 miles
A cyclist bikes at a constant speed for 18 miles. He then returns home at the same speed, but takes a different route. His return trip takes one hour longer and is 23 miles. Find his speed...
1 answers
QUESTION 54 Because of ARDS, cells switch from fermentation to aerobic respiration in order to produce...
QUESTION 54 Because of ARDS, cells switch from fermentation to aerobic respiration in order to produce ATP. True False...
1 answers
A company has 1,500 units in ending work in process that are 20% complete after transferring...
A company has 1,500 units in ending work in process that are 20% complete after transferring out 10,000 units. All materials are added at the beginning of the process. If the cost per unit is $3 for materials and $6 for conversion, what is the cost of units transferred out and in ending work in proc...
1 answers
Question 1 State the difference between the following: - Population and Sample. - Parameter and Statistics....
Question 1 State the difference between the following: - Population and Sample. - Parameter and Statistics. Question 2 Abby samples the next 40 cracker bags packed by the machine to determine whether it is putting 454 g of crackers in each bag. The sample statistics are as follows: M = 462 g; s = 16...
1 answers
Stacy and Michael plan to retire in 40 years. How much do they need to deposit...
Stacy and Michael plan to retire in 40 years. How much do they need to deposit each month in a sinking fund in order to have $750,000 when they retire if they earn 4.8% compounded monthly. Please show work. Thanks you...
1 answers
Microbiotics currently sells all of its frozen dinners cash-on-delivery but believes it can increase sales by...
Microbiotics currently sells all of its frozen dinners cash-on-delivery but believes it can increase sales by offering supermarkets 1 month of free credit. The price per carton is $70, and the cost per carton is $50. The unit sales will increase from 1,020 cartons to 1080 per month If credit is gran...
1 answers
(1 point) You must design a closed rectangular box of width w, length 1 and height...
(1 point) You must design a closed rectangular box of width w, length 1 and height h, whose volume is 530 cm . The sides of the box cost 3 cents/cm2 and the top and bottom cost 5 cents/cm². Find the dimensions of the box that minimize the total cost of the materials used. dimensions = (Enter yo...
1 answers
Mark for follow up Question 45 of 75. Manuel's home was destroyed in Hurricane Irma and...
Mark for follow up Question 45 of 75. Manuel's home was destroyed in Hurricane Irma and he qualified for a disaster distribution. He withdrew from his IRA on October 30, 2017, which he included in his gross income on his 2017 tax return. In 2015, Manuel was stieto deposit $60,000 in his IRA. Wha...
1 answers
CHAPTER 9 (10 pts) Alkynes are very similar in reactivity to alkenes. What product is obtained...
CHAPTER 9 (10 pts) Alkynes are very similar in reactivity to alkenes. What product is obtained when the following reagents are added to 1-hexyne? 1. (a) molecular hydrogen/Pd/CaCOs (Lindlar's catalyst) (b) 1 mol HBr/peroxides (e cold, dilute KMnO4 (d) H2O, HgSO/H2SO4 (e) Sia BH, NaOH and H2O2...
1 answers
There are multiple screenshots including the entire problem. I stopped the two assets pictures on the...
There are multiple screenshots including the entire problem. I stopped the two assets pictures on the same "0" for help The following is the ending balances of accounts at December 31, 2018 for the Vos Cash Short-term investments Accounts receivable Long-term investmentsS Inventories ...
1 answers
N stock is issued for an amount greater than par value 8. should be credited to...
n stock is issued for an amount greater than par value 8. should be credited to a. Retained Earnings b. Cash c. Legal Capital d. Paid-in Capital in Excess of Par e. Unrealized Holding Gains and Losses-Equity to record the amortization of a premium on bonds payable is a. Premium on Bonds Payable b. I...
1 answers
Lithium reacts with nitrogen gas according to the following reaction: 6Li(s)+N2(g)?2Li3N(s) What mass of lithium is...
Lithium reacts with nitrogen gas according to the following reaction: 6Li(s)+N2(g)?2Li3N(s) What mass of lithium is required to react completely with 55.4 mL of N2 gas at STP? Express your answer in grams....
1 answers
Digital Forensics You are investigating a case of industrial espionage for a company called Superior Bicycles....
Digital Forensics You are investigating a case of industrial espionage for a company called Superior Bicycles. A disk image was acquired from a suspected employee, Chris Murphy’s computer that was seized as part of the investigation. The disk is a Windows drive formatted in NTFS. Your task is ...
1 answers
The amplitude of an oscillator decreases to 58.1 %of its initial value in 21.0 s ....
The amplitude of an oscillator decreases to 58.1 %of its initial value in 21.0 s . What is the value of the time constant?...
1 answers
10) During your investigations of the bird species Biondo's night heron on the FGCU campus, you...
10) During your investigations of the bird species Biondo's night heron on the FGCU campus, you encounter two contrasting strains of individuals. Strain 1 has white beaks and green eyes. Strain two has black beaks and yellow eyes. You cross strain 1 females with strain 2 males. The resulting Fi&...
1 answers
What is a possible mechanism for the disruption of protein degradation pathways? please be detailed.
what is a possible mechanism for the disruption of protein degradation pathways? please be detailed....
1 answers
Erin is a 28-year-old professional woman who is 5 feet 8 inches tall and vigilantly maintains her weight at 118...
Erin is a 28-year-old professional woman who is 5 feet 8 inches tall and vigilantly maintains her weight at 118 pounds by following a lacto-ovo (non-fat milk and egg whites only) vegetarian diet that supplies approximately 1200 calories a day. With her understanding that protein should provide betwe...

-- 0.049475--