Question: using c language Rewrite the following code WITHOUT USING THE string.h library . The output should stay the same Please provide a screenshot of the

using c language
Rewrite the following code WITHOUT USING THE string.h library . The output should stay the same
Please provide a screenshot of the code .
#include
int my_function(char classroom[][6], int num_row, char lst[]){
int flag = 0;
int num_col = 6;
int index = 0;
for(int i = 0; i < num_row ; i++){
for(int j = 0; j < num_col;j++){
if(classroom[i][j] == 'X')
{
continue;
}
else{
//check left
if(j-1 >=0 && classroom[i][j-1]!='X'){
lst[index++] = classroom[i][j];
flag = 1;
continue;
}
//check right
if(j+1 < num_col && classroom[i][j+1] != 'X'){
lst[index++] = classroom[i][j];
flag = 1;
continue;
}
//check below
if(i+1 < num_row && classroom[i+1][j] != 'X'){
lst[index++] = classroom[i][j];
flag = 1;
continue;
}
//check up
if(i-1 >=0 && classroom[i-1][j] != 'X'){
lst[index++] = classroom[i][j];
flag = 1;
continue;
}
}
}
}
if(flag)
return 0;
else{
return 1;
}
}
int main()
{
char classroom[][6] = {{'A','X','H','X','n','X'},
{'X','q','I','X','e','K'},
{'b','X','X','J','X','E'}};
int num_col = 6;
int num_row = 3;
char lst[num_col*num_row];
my_function(classroom,num_row,lst);
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!