Answer to Question #258008 in C for joe

Question #258008

Write a C program which reads and access the elements of the csv file by using the system call functions such as read, write and open. You should sum all the no. present inside a particular column in that csv file by using the words pthread_create and pthread_join only .


1
Expert's answer
2021-10-28T12:37:40-0400
#include <stdio.h>
#include <stdlib.h>


int main(){
    int sum1=0;
    FILE *file;
    file = fopen("myFile.csv", "r");
    int arr[50];
    int i;
    
    if (file == NULL){
        printf("\nError");
        exit (0);
    }


    for (i = 0; i < 10; i++){
        fscanf(file, "%d,", &arr[i] );
    }
    for (i = 0; i < 10; i++){
        sum1=sum1+(arr[i]);
    }
    
    fclose(file);
    printf("\nSum is: %d", sum1);
    return 0;


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS