Hi, well i take lots of time figuring this out.
I need a program that tells me the coordinates of a word that is in other array,
what I have gotten is the y coordinate "the column", but
I need to do the case for a bidimentional array
get the x coordinate too "the row".
so this look like
hard //word to be found//
blablablablablabalblablabalbla //the puzzle where the word is
imtriyingtodomybestbutishard
blablablablablbalablabalabalbl
so the result i get from this is : (2,25) //row, column//
IN THE EXAMPLE I ONLY GET THE 25, AND I NEED TO GET THE 2 TOO
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
main()
{
int coordenada(char *string, char *target);
printf("%d\n", coordenada("mellevalachingadaporqueestoestamalplan", "mal"));
getch();
return 0;
}
//returns the position of t in s//
int coordenada(char *s,char *t)
{
char *p;
for(p = s; *p != '\0';p++) //p runs trough s //
{
char *x, *y; //the first letter 'y' = 't'//
x=p; //now keep going til find the end of the word//
y=t;
for(; *x != '\0' && *y != '\0' && *x == *y; x++, y++);
if(*y == '\0') //we get to the end of the word
return p - s + 1; //this gives the coordinate 'y'//
}
return -1;
//if it fails//
}
PLEASE HELP ME , I NEED TO FINISH THIS BY THE END OF THIS DAY
PLEASE!!:-|