Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help writing this code, please write it in C and not C++ c - This program

ID: 3594445 • Letter: I

Question

I need help writing this code, please write it in C and not C++

c - This program is a modification of one you did for lab six. Th ts single command line argument and prints the number of upper- case letters, 2. e program takes Name this program count. the name of an input file as lower case letters, and digits found in each word. No word will ever be longer than 50 characters. A sample command linea execution is shown below The file DATA ./a.out DATA AlAbAmA4 Est. 1831 1 uppercase, 2 lowercase, 4 digits Crimson 1 uppercase, 6 lowercase, 0 digits TIDE#1-4 uppercase, 0 lowercase , 1 digits AlAbAmA Est. 1831 Crimson TIDE#1 - 4 uppercase, 3 lowercase, 0 digits . Your program should confirm the input file exists (exit with an appropriate error message if it does not). n to count the number of uppercase, lowercase, and digits in a given word. The function must use the signature shown below void countC ase (char*,int*,int *,int *) lowercase letters, and digits to This function passes a string and returns the number of uppercase letters, the calling routine through the second, third, and fourth parameters.

Explanation / Answer

Copy the code in count.c and then compile and run

Compile command : gcc count.c

Run command : ./a.out DATA

Code snippet:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void countCase(char*, int*, int*, int*);
int main(int argc, char** argv)
{
FILE * fp;
char * line = NULL;
size_t len = 0;
ssize_t read;
char *filePath= malloc(100);

if(argc<2){
fprintf(stderr, "Please specify the Input file (DATA) as the first argument. ");
exit(-1);
} else {
strcpy(filePath, argv[1]);
}
fp = fopen(filePath, "r");
if (fp == NULL) {
fprintf(stderr, "The input file does not exist ");
exit(EXIT_FAILURE);
}

while ((read = getline(&line, &len, fp)) != -1) {
line[strcspn(line, " ")] = '';
int upperCount=0, lowerCount=0, digitCount=0;
countCase(line,&upperCount,&lowerCount,&digitCount);
printf("%s - %d uppsecase, %d lowercase, %d digits ", line, upperCount, lowerCount, digitCount);
}

fclose(fp);
if (line)
free(line);
exit(EXIT_SUCCESS);
}

void countCase(char* str, int* upperCount, int* lowerCount, int* digitCount) {
char* charPtr = str;
char c;
while ( charPtr != NULL && *charPtr != '')
{
c = *charPtr;
if (c >= 65 && c <= 100) (*upperCount)++;
if (c >= 97 && c <= 122) (*lowerCount)++;
if (c >= 48 && c <= 57) (*digitCount)++;
++charPtr;
}
}