Significado de: if(datos[i].nombre[0]),
Pues lo dicho, en el contexto de la siguiente función, qué significado tiene
la expresión: if(datos[i].nombre[0]), sobre todo el cero entre corchetes.
¿A qué sería equivalente?
Gracias anticipadas;
JohnMe
/***************************************************************************
***
* MOSTRAR LISTADO EN FICHERO DE TEXTO
*
****************************************************************************
***/
void listar_a_texto(void)
{
int i;
FILE*destino;
char fichero[80];
gotoxy(15,18);
textcolor(WHITE);
cprintf("Introduce la ruta del archivo destino: n");
fflush(stdin);
gotoxy(54,18);
gets(fichero);
if ((destino=fopen(fichero,"w"))==NULL)
{
gotoxy(20,20);
cprintf("No se pudo abrir el archivo");
gotoxy(1,25);
cprintf("Presione una tecla para continuar ...");
getch();
}
else
{
gotoxy(25,22);
textcolor(YELLOW);
textbackground(RED);
cprintf("*** Archivo de salida generado ***");
gotoxy(1,25);
system("pause");
fprintf(destino,"NOMBRE APELLIDO 1 APELLIDO 2 DIRECCION
TFNO.FIJO TFNO.MOVILn");
fprintf(destino,"------------ ------------ ------------- -------------------
--------- ----------n");
for (i=0;i<cuenta_personas;i++)
{
if(datos[i].nombre[0])
{
fprintf(destino,"%-12s %-12s %-13s %-19s %-9s %-9sn",
datos[i].nombre,datos[i].primer_apellido,datos[i].segundo_apellido,datos[i].
direccion,datos[i].telefono,datos[i].movil);
}
}
}
fclose(destino);
}
la expresión: if(datos[i].nombre[0]), sobre todo el cero entre corchetes.
¿A qué sería equivalente?
Gracias anticipadas;
JohnMe
/***************************************************************************
***
* MOSTRAR LISTADO EN FICHERO DE TEXTO
*
****************************************************************************
***/
void listar_a_texto(void)
{
int i;
FILE*destino;
char fichero[80];
gotoxy(15,18);
textcolor(WHITE);
cprintf("Introduce la ruta del archivo destino: n");
fflush(stdin);
gotoxy(54,18);
gets(fichero);
if ((destino=fopen(fichero,"w"))==NULL)
{
gotoxy(20,20);
cprintf("No se pudo abrir el archivo");
gotoxy(1,25);
cprintf("Presione una tecla para continuar ...");
getch();
}
else
{
gotoxy(25,22);
textcolor(YELLOW);
textbackground(RED);
cprintf("*** Archivo de salida generado ***");
gotoxy(1,25);
system("pause");
fprintf(destino,"NOMBRE APELLIDO 1 APELLIDO 2 DIRECCION
TFNO.FIJO TFNO.MOVILn");
fprintf(destino,"------------ ------------ ------------- -------------------
--------- ----------n");
for (i=0;i<cuenta_personas;i++)
{
if(datos[i].nombre[0])
{
fprintf(destino,"%-12s %-12s %-13s %-19s %-9s %-9sn",
datos[i].nombre,datos[i].primer_apellido,datos[i].segundo_apellido,datos[i].
direccion,datos[i].telefono,datos[i].movil);
}
}
}
fclose(destino);
}
if(datos[i].nombre[0])
equivalencias : if(datos[i].nombre[0]==NULL)
datos[i].nombre[0] es un apuntador if(datos[i].nombre[0]== )
lo que kiere decier exactamente es que si existe un valor en datos[i].nombre[0] entoces se cumple el if
zod :D ojala me hallas entendido
equivalencias : if(datos[i].nombre[0]==NULL)
datos[i].nombre[0] es un apuntador if(datos[i].nombre[0]== )
lo que kiere decier exactamente es que si existe un valor en datos[i].nombre[0] entoces se cumple el if
zod :D ojala me hallas entendido
