<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
nombres es un array de 100 posiciones tipo Cadena40 que es un char de 40 posiciones, la funcion<br>strlen debe recibir una sola cadena de caracteres para saber el numero de estos caracteres,<br>correria con algo como strlen(nombres["Posicion"]);<br><br>***************************************************************************<br>Subject: [C con Clase] Funcion strlen me da error el printf<br><br>



<style>
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Verdana;}
</style>


Hola a todos:<br>
mire aqui les adjunto el programa q esta hecho con el dev c++, para q me puedan ayudar, hice tantas modificaciones, pero nada sigue saltando el mismo error. <br>
 <br>
gracias<br>
atte:Laura Costabel<br>
lista con clase C<br>
 <br>
#include<stdio.h><br>#include<conio.c><br>#include<string.h><br>
typedef char Cadena40 [40];<br>Cadena40 nombres [100];<br>    <br>/* <br> * comparar implementa comparacion de nombres<br> */<br>int comparar(int i, int j) {<br>//     printf("%s - %s - %d \n", nombres[i], nombres[j], strcmp(nombres[i], nombres[j]));<br>     return strcmp(nombres[i], nombres[j]);<br>} // end comparar()<br>
/* <br> * swap implementa el intercambio de valores<br> */<br>void swap(int i, int j) {<br>     char aux[40];<br>//     printf("%s - %s \n", nombres[i], nombres[j]);<br>     strcpy(aux, nombres[i]);<br>//     printf("Swap %s \n", aux);<br>     strcpy(nombres[i], nombres[j]);<br>     strcpy(nombres[j], aux);<br>//     printf("%s - %s \n", nombres[i], nombres[j]);<br>} // end swap()<br>
/* <br> * ordenar implementa ordenamiento ascendente de nombres<br> */<br>void ordenar(int cantidadpersonas) {<br>     for (int i = 0; i < cantidadpersonas - 1; i++) {<br>         for(int j = i + 1; j < cantidadpersonas; j++) {<br>  //               printf("%s - %s \n", nombres[i], nombres[j]);<br>                 if(comparar(i, j) == 1) {<br>                      swap(i, j);<br>                 }<br>         }<br>     }<br>} // end ordenar()<br>
/* <br> * mostrar implementa mostrar los nombres<br> */<br>void mostrar(int cantidadpersonas) {<br>     for (int i = 0;  i < cantidadpersonas; i++) {<br>          printf("\n %d  %s ", i, nombres[i]);<br>     }<br>     printf("\n Oprima return para continuar ...");<br>     getch();<br>} // end mostrar()<br>
/*<br> * main Rutina principal<br> */<br>
<br>//* Comparamos para la longitud<br>int comlen(int i, int j) {<br>//     printf("%s - %s - %d \n", nombres[i], nombres[j], strcmp(nombres[i], nombres[j]));<br>     int a = strlen (nombres [i]);<br>     int b = strlen (nombres [j]);<br>     int c;<br>     if (a==b) c=0;<br>        else if (a<b) c=-1;<br>        else c=1;      <br>     return c;<br>} // end comparar()<br>
//* Ordenamos para la longitud<br>void ordlen(int cantidadpersonas) {<br>     for (int i = 0; i < cantidadpersonas - 1; i++) {<br>         for(int j = i + 1; j < cantidadpersonas; j++) {<br>  //               printf("%s - %s \n", nombres[i], nombres[j]);<br>                 if(comlen(i, j) == 1) {<br>                      swap(i, j);<br>                 }<br>         }<br>     }<br>} // end ordenar()<br>
<br>int main () {<br>     int cantidadpersonas;<br>     // Ingresar cantidad de personas<br>     printf("\n Ingrese la cantidad de la lista de personas: ");<br>     scanf("%d",&cantidadpersonas);<br>     // Ingresar los nombres<br>     for (int i = 0;  i < cantidadpersonas; i++) {<br>          printf("\n Introducir el nombre %d : ", i);<br>          scanf("%s", &nombres[i]);<br>     }<br>     // Mostrar nombres ingresados<br>     mostrar(cantidadpersonas);<br>     // Ordenar la lista de nombres<br>     ordenar(cantidadpersonas);<br>     // Mostrar lista ordenada<br>     printf("\n\n LISTA ORDENADA ALFABETICAMENTE\n");<br>     <br>        <br>     mostrar(cantidadpersonas);<br>     printf("\n\n LISTA ORDENADA POR LONGITUD\n");<br>     <font style="background-color: rgb(255, 255, 0);">//*    printf("\n La longitud de\"%s\" es %d", nombres,strlen(nombres);// esto me da error no se porque</font><br>     <br>     ordlen(cantidadpersonas);<br>     // Mostrar lista ordenada  <br>     mostrar(cantidadpersonas);<br>     return 0;<br>} // end main()<br><br>                                      <br><hr>Guardá y compartí fotos, archivos, documentos y más. <a href="http://skydrive.live.com">¡Con Windows Live tienes 25 GB gratis! Probalo ahora.</a>                                     <br /><hr />Connect to the next generation of MSN Messenger   <a href='http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline' target='_new'>Get it now! </a></body>
</html>