Ver Mensaje Individual
  #7 (permalink)  
Antiguo 09/05/2008, 18:16
groxman11
 
Fecha de Ingreso: mayo-2008
Ubicación: argentina
Mensajes: 5
Antigüedad: 16 años
Puntos: 0
Exclamación Re: Insertar Palabras En Un Arreglo

/*SE QUE ES UN POCO LARGO TODA LA DESCRIPCION PERO POR FAVOR LEANLO*/


bueno es cierto todo lo que dicen, sobre las bibliotecas que debo introducir, para determinada funcione, y que al final de un arreglo hay un nulo, o un espacio vacio que indica el final del arreglo.

arreglo[5][10];

el llenado de los arreglos, en este caso lo estas haciendo con la funcion strcpy, que tiene 2 parametros, generlamente 2 punteros, o dos arreglos, que serian casi lo mismo, bueno esta funcion copia lo que hay en el segundo arreglo y lo superpone en el primer arreglo. strcpy(parm1,parm2);

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 f e l i n o
1 n o s e
2 m a s c o t a
3 o t r a p a l a b r a
4 o t r a m a s


cuando tu declaras
strcpy(arreglo[0][],"felino"); estas copiando la cadena "felino" en el arreglo de la fila 0 y no pones columan por que supongo que la cadena de caracteres definira el tamaño del arreglo.
BUENO COMO VERAN ENTIENDO TODO. AL MENOS SI ESO ES LO QUE ME HAN QUERIDO TRASNMITIR, EL PROBLEMA AHORA YA NO ES COMO EMPIEZO SI NO QUE CUANDO CORRO EL PROGRAMA ME SALEN ERRORES EN LA PARTE DE strcpy el error es :error de sintaxys en funcion main

bueno no se si ustedes provaron correr el programa, en el "borland turbo c" en ese compilador no funciona
EL PROGRAMA ES :
#include<stdio.h>
#include<string.h>
main(){
char arreglo[5][10]; /* 5 cadenas de longitud 10*/

/*aca lo llenas*/

strcpy(arreglo[0][],"felino");
strcpy(arreglo[1][],"no se"); /*los errores me salen aqui*/
strcpy(arreglo[2][],"mascota");
strcpy(arreglo[3][],"otra palabra");
strcpy(arreglo[4][],"otra mas");

/*luego imprimes */

for (int i=0;i<5;i++){
printf("%s\n",arreglo[i][]);

}
getch();
}

VUELVO A DECIR AHORA LA CONSIGNA ES UN PROGRAMA QUE EN UN ARREGLO PUEDA ALMACENAR PALABRAS PARA LUEGO IMPRIMIRLAS, COMPARARLAS, CAMBIARLAS, PARA LO CUAL EL ACCESO A CADA PALABRA DEBE SER FACIL, ASI COMO EL ACCESO AL CONJUNTO DE TODO EL ARREGLO TMB, POR EJEMPLO PUEDO NECEISTAR COMPARAR UNA PALABRA X CON TODAS LAS PALABRAS Y DEL ARREGLO.

SI EL ARREGLO TIENE: "hola, bien, mal"
comparar por medio de un ciclo la palabra "chao", con "hola,bien,mal" una por una, y decir si son iguales o algo parecido.
BUENO PERO POR LO MIENTRAS CON QUE CORRA EL PROGRAMA ME HES SUFICIENTE EL CAMBIO DE PALABRAS Y LA IMPRESION Y COMPARACION SON SECUNDARIOS.

LES PIDO ENCARECIDAMENTE QUE ME SIGAN AYUDANDO DESDE YA GRACIAS.