I'm programming a word hunting and a problems in the void function is making it difficult. In the code I use functions to scan the array in all directions and returns me the start and end coordinates or exit the function and start reading in another direction, then my doubt is born, it is possible to exit the function, as I indicated with #### #, or do an int function with return 0? Help me with this code and if you notice another error in the code sign me.
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void Norte (char cacapalavra[][100], char palavra[], int pc, int pl) {
int i, j, n, k;
j = pc; k = 0;
n = strlen(palavra);
for (i = pl; i < i+n; i++) {
if (cacapalavra [i][j] != palavra[k]) ######;
else k++;
}
printf ("%d %d", pc, pl);
printf("%d %d", i, j);
}
void Sul (char cacapalavra[][100], char palavra[], int pc, int pl) {
int i, j, n, k;
j = pc; k = 0;
n = strlen(palavra);
for (i = pl; i < i+n; i++) {
if (cacapalavra [i][j] != palavra[k]) #####;
else k++;
}
printf ("%d %d", pc, pl);
printf("%d %d", i, j);
}
void Leste (char cacapalavra[][100], char palavra[], int pc, int pl) {
int i, j, n, k;
i = pl; k = 0;
n = strlen(palavra);
for (j = pc; j < j+n; j++) {
if (cacapalavra [i][j] != palavra[k]) #####;
else k++;
}
printf ("%d %d", pc, pl);
printf("%d %d", i, j);
}
void Oeste (char cacapalavra[][100], char palavra[], int pc, int pl) {
int i, j, n, k;
i = pl; k = 0;
n = strlen(palavra);
for (j = pc; j < j+n; j--) {
if (cacapalavra [i][j] != palavra[k]) #####;
else k++;
}
printf ("%d %d", pc, pl);
printf("%d %d", i, j);
}
void Nordeste (char cacapalavra[][100], char palavra[], int pc, int pl) {
int i, j, n, k;
k = 0;
n = strlen(palavra);
for (i = pl, j = pc; i < i+n; j++, i--) {
if (cacapalavra [i][j] != palavra[k]) #####;
else k++;
}
printf ("%d %d", pc, pl);
printf("%d %d", i, j);
}
void Noroeste (char cacapalavra[][100], char palavra[], int pc, int pl) {
int i, j, n, k;
k = 0;
n = strlen(palavra);
for (i = pl, j = pc; i < i+n; j--, i--) {
if (cacapalavra [i][j] != palavra[k]) #####;
else k++;
}
printf ("%d %d", pc, pl);
printf("%d %d", i, j);
}
void Sudeste (char cacapalavra[][100], char palavra[], int pc, int pl) {
int i, j, n, k;
k = 0;
n = strlen(palavra);
for (i = pl, j = pc; i < i+n; j--, i++) {
if (cacapalavra [i][j] != palavra[k]) #####;
else k++;
}
printf ("%d %d", pc, pl);
printf("%d %d", i, j);
}
void Sudoeste (char cacapalavra[][100], char palavra[], int pc, int pl) {
int i, j, n, k;
k = 0;
n = strlen(palavra);
for (i = pl, j = pc; i < i+n; j++, i++) {
if (cacapalavra [i][j] != palavra[k]) ######;
else k++;
}
printf ("%d %d", pc, pl);
printf("%d %d", i, j);
}
int main () {
char cacapalavra [100][100];
char palavra [100];
int i, j, k, n, pc, pl;
k = 0;
scanf ("%d", &n);
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
scanf ("%c", &cacapalavra[i][j]);
scanf ("%s", palavra);
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
if (palavra[k] == cacapalavra[i][j]) {
pc = j; pl = i;
Norte(cacapalavra, palavra, pc, pl);
Sul(cacapalavra, palavra, pc, pl);
Leste(cacapalavra, palavra, pc, pl);
Oeste(cacapalavra, palavra, pc, pl);
Nordeste(cacapalavra, palavra, pc, pl);
Noroeste(cacapalavra, palavra, pc, pl);
Sudeste(cacapalavra, palavra, pc, pl);
Sudoeste(cacapalavra, palavra, pc, pl);
}
}
}
return 0;
}