https://wiki.cabal.mx/index.php?title=Curso_de_Programaci%C3%B3n_en_C/Prog91&feed=atom&action=history
Curso de Programación en C/Prog91 - Historial de revisiones
2024-03-28T23:33:40Z
Historial de revisiones para esta página en el wiki
MediaWiki 1.32.1
https://wiki.cabal.mx/index.php?title=Curso_de_Programaci%C3%B3n_en_C/Prog91&diff=3782&oldid=prev
Rrc: /* Prog91 */
2012-06-17T12:34:09Z
<p><span dir="auto"><span class="autocomment">Prog91</span></span></p>
<p><b>Página nueva</b></p><div>__NOTOC__<br />
* [[:#Prog91| strncmp()]]<br />
** [[:#Resultado | Resultado]]<br />
** [[:#Explicación | Explicación]]<br />
<br />
== Prog91 ==<br />
<br />
<syntaxhighlight lang="c" line="GESHI_FANCY_LINE_NUMBERS"><br />
<br />
#include <stdio.h><br />
#include <string.h><br />
<br />
#define TAMONODELISTA 5<br />
<br />
int main( void )<br />
{<br />
const char * lista[TAMONODELISTA] =<br />
{<br />
"astronomy", "astounding",<br />
"astrophysics", "ostracize",<br />
"asterism"<br />
};<br />
<br />
int count = 0,<br />
i;<br />
<br />
for( i = 0; i < TAMONODELISTA; i++ )<br />
if( !strncmp( lista[i], "astro", 5 ) )<br />
// if( !strncmp( *(lista + i ), "astro", 5 ) )<br />
{<br />
printf( "Descubrí: %s\n", lista[i] );<br />
count++;<br />
}<br />
<br />
printf( "La lista tiene %d palabras inicando"<br />
" con astro.\n", count);<br />
<br />
return 0;<br />
}<br />
<br />
</syntaxhighlight><br />
<br />
=== Resultado ===<br />
<br />
[rrc@llawyr CClase]$ gcc -Wall -o Prog91 Prog91.c<br />
[rrc@llawyr CClase]$ ./Prog91<br />
Descubrí: astronomy<br />
Descubrí: astrophysics<br />
La lista tiene 2 palabras inicando con astro.<br />
[rrc@llawyr CClase]$ cat Prog91.c<br />
<br />
=== Explicación ===<br />
<br />
[[Category:Programación en C]]<br />
[[Category:CCabal]]<br />
[[Category:CursoC]]</div>
Rrc