solve and run this program Problem 2: In the following the C function named cc t
ID: 3683007 • Letter: S
Question
solve and run this program
Explanation / Answer
int const NR = 1;
int const NC = 1; //Define the constants
int const NCC = 1;
void cc(char arr[NR][NC],char locations[NCC][2],char ch,int** count)
{
int count1=0;
for(int i=0;i<NR;i++)
for(int j=0;j<NC;j++)
{
if(arr[i][j]==ch)
{
locations[i][j]=ch;
count1++;
}
}
*count = (int*) malloc(sizeof(int));
(*(*count)) = count1;
}
int main()
{
FILE *ptr_file;
char buf[1000];
ptr_file =fopen("input.txt","r");
if (!ptr_file)
return 1;
while (fgets(buf,1000, ptr_file)!=NULL)
//handle how the data from the file is to be stored in the array. Details for the same aren't mentioned.
char ch;
char locations[NCC][2];
char arr[NR][NC];
printf("Enter the character to be searched: ");
scanf("%c",ch);
int *count=NULL;
cc(arr,locations,ch,&count);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.