Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 2, 2021 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/df9e83fb78de5f5e63011cac6bd3d545 to your computer and use it in GitHub Desktop.
Save parzibyte/df9e83fb78de5f5e63011cac6bd3d545 to your computer and use it in GitHub Desktop.
/*
https://parzibyte.me/blog
*/
#include <stdio.h>
#include <string.h>
int main(int argc, char const *argv[])
{
char texto[] = "Hola, mundo. Me llamo Luis y me gusta programar en PHP";
char busqueda[] = "PHP";
char *posiblePuntero = strstr(texto, busqueda);
if (posiblePuntero != NULL)
{
int indice = posiblePuntero - texto;
printf("La cadena '%s' contiene la subcadena '%s' en la posición %d", texto, busqueda, indice);
}
else
{
printf("La cadena '%s' NO contiene la subcadena '%s'", texto, busqueda);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment