Answer:
Check the explanation
Step-by-step explanation:
#// do comment if any problem arises
//code
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
void read(FILE *input, char array[10][61])
{
// read all 10 strings
for (int i = 0; i < 10; i++)
fgets(array[i], 60, input);
}
void remove_newline(char array[10][61])
{
for (int i = 0; i < 10; i++)
{
array[i][strlen(array[i]) - 1] = '\0';
}
}
void smallest(char array[10][61])
{
int s = 0;
for (int i = 1; i < 10; i++)
{
if (strlen(array[s]) > strlen(array[i]))
s = i;
}
printf("\\Smallest strnig: %s\\", array[s]);
}
void upper(char array[10][61])
{
for (int i = 0; i < 10; i++)
{
int n = strlen(array[i]);
for (int j = 0; j < n; j++)
{
array[i][j] = toupper(array[i][j]);
}
}
}
int main()
{
char filename[30];
// array of 10 strings
char array[10][61];
printf("Enter filename: ");
gets(filename);
// open file
FILE *input = fopen(filename, "r");
// read into array
read(input, array);
// close file
fclose(input);
// remove newline
remove_newline(array);
// print
printf("Contents of file:\\");
for (int i = 0; i < 10; i++)
printf("%s\\", array[i]);
// print smallest string
smallest(array);
// uppercase
upper(array);
// print again
printf("\\Contents of file after converting to uppercase:\\");
for (int i = 0; i < 10; i++)
printf("%s\\", array[i]);
}
kindly check the attached image below to see the Output: