Foros del Web » Programación para mayores de 30 ;) » Programación General »

Donde consigo ejemplos con while en Turbo C??

Estas en el tema de Donde consigo ejemplos con while en Turbo C?? en el foro de Programación General en Foros del Web. Como dije en le post donde puedo conseguir información básica (sintaxis básicas) para turbo C, por que nose que pasa en este ejemplo que me ...
  #1 (permalink)  
Antiguo 10/11/2005, 12:12
Avatar de Nova  
Fecha de Ingreso: enero-2003
Ubicación: Hyo
Mensajes: 832
Antigüedad: 21 años, 3 meses
Puntos: 1
Donde consigo ejemplos con while en Turbo C??

Como dije en le post donde puedo conseguir información básica (sintaxis básicas) para turbo C, por que nose que pasa en este ejemplo que me sale error en las lineas de while y otras lineas.
Cita:
/* programa transfer.c
(c) Vicente Garceran Hernandez 1992
PROGRAMA DE TRANSFERENCIA DE DATOS ENTRE DOS ORDENADORES
UTILIZANDO CONTROL POR SOFTWARE.
------------------------------------------------------
PARAMETRO DE LA COMUNICACION
9600 BAUDIOS
SIN PARIDAD
2 BIT DE PARADA
8 BITS DE DATOS
------------------------------------------------------
*/
/* DIRECTIVAS DEL PREPROECSADOR*/
#define TRUE 1
#define PARAM 0 x E7 /*PARAMETROS COMUNICACION: 1110
0111 = E7H*/
#include <dos.h>
#include <stdio.h>
#include <io.h>
#include <fcnt1.h>
/*DEFINICION DE LAS FUNCIONES*/
void inicia_puerto();
char estado_puerto();
void envia_byte();
char lee_byte();
void etx_puerto();
void envia_nombre_archivo();
void lee_nombre_archivo();
void envia_archivo();
void recibe_archivo();

int port;
main(void)
while (TRUE)
{
system("cls");
printf("MENU DEL PROGRAMA DE TRANSMISION");
printf("________________________________");
printf(" tE-ENVIAR ARCHIVO.n");
printf(" tR-RECIBIR ARCHIVO.n");
printf/" tX-SALIR DEL PROGRAMA.n");
swicht(toupper(getche()))
{
case'E': envia_archivo();
break;
case'R': recibe_archivo();
break;
case'X': exit(0);
}
}
/*================FIN del main()==========*/
void inicia_puerto()/*INICIAL EL PUERTO COM, SEGUN PARAM*/
union REGS regs;
regs.h.ah=0x00;
regs.x.dx=port;
regs.h.al=PARAM;
int86(0x14, &regs, &regs);
/*================FIN de inicia_puerto()==========*/
char estado_puerto()/*LEE EL ESTADO DEL PUERTO COM*/
union REGS regs;
regs.h.ah=0x03;
regs.x.dx=port;
int86(0x14, &regs, &regs);
if(regs.h.ah & 0x80) printf("\t TIEMPO EXCEDISO n");
if(regs.h.ah & 0x40) printf("\t TSR VACIO");
if(regs.h.ah & 0x20) printf("\t THR VACIO");
if(regs.h.ah & 0x10) printf("\t INTERRUPCION");
if(regs.h.ah & 0x08) printf("\t ERROR DE TRAMA");
if(regs.h.ah & 0x04) printf("\t ERROR DE PARIDAD");
if(regs.h.ah & 0x02) printf("\t ERROR DE SOBRECARGA");

return(regs.h.ah);
}
/*=================FIN de estado_puerto()============*/
void enivia_byte(byte)/*ENVIA CARACTER POR EL PUERTO SERIE*/
char byte;
{
union REGS regs;
regs.h.ah = 0x01;
regs.h.dx=port;
regs.h.al=byte;
int86(0x14, &regs, &regs);
if(regs.h.ah & 0x80)
{
printf("\t ERROR DE TRANSMISION");
exit(1);
}
}
/*===============FIN de enviar_byte()============*/
char lee_byte()/*LEE CARACTER DE PUERTO SERIE*/
{
union REGS regs;
/*PRUEBA QUE SE HA RECIBIDO UN CARACTER*/
while(!(estado_puerto() &0x01))
if(kbhit())/*TERMINA SI SE PULSA UNA TECLA*/
{
getch();
exit(1);
}
regs.h.ah=0x02;
regs.x.dx=port;
int86(0x14, &regs, &regs);
if(regs.h.ah & 0x80)
{
prinft("\t ERROR DE LECTURA");
exit(1);
}
return(regs.h.al);
}
/*===============FIN de lee_byte===============*/
void ext_puerto()/*ESPERA RECIBIR CARACTER ETX*/
char c;
c=lee_byte();
if(c!='@')
{
printf("\t DATO NO RECIBIDO... FIN TRANSMISION n");
exit(1);
}
/*==========FIN de etx_puerto()===============*/
void envia_nombre_archivo(ena)/*ENVIA EL NOMBRE DEL ARCHIVO*/
char *ena;
printf("\t TRANSMITIENDO ARCHIVO: %s\n" ena);
do
{
envia_byte('|');/* emviar caracter STX*/
}
while(!kbhit() && !(estado_puerto() & OXFF));
if(kbhit())
{
getch();
printf("\t TECLA PULSADA...FIN DE TRANSMISION n);
exit(1);
}
etx_puerto();/*espera caracter EXT*/
while(*ena)
{
envia_byte(*ena++);
etx_puerto();
}
envia_byte('0'); /* envia caracter nulo*/
}
/*=================FIN de envia_nombre_archivo()==========*/
void lee_nombre_archivo(lna)/*LEEEL NOMBRE DEL ARCHIVO*/
char *lna;
{
printf(\t ESPERA RECIBIR NOMBRE DE ARCHIVO\N");
while (lee_byte() !='|');
envia_byte('@')
while((*lna==lee_byte()))
{
if(*lna !='|')
{
lna++;
envia_byte('@')
}
}
/*=============FIN de lee_nombre_archivo()============*/
viod envia_nombre_archivo()/*OPCIONEN ENVIAR ARCHIVO*/
{
FILE *fp;
char n_archivo[12];
int handle;
int i;
long unsigned int if;
union
{
char byte_archivo[3];
long unsigned int file;
}
longitud;
/*PREGUNTA NUMERO DEL PUERTO SERIE COM*/
printf ("\n NUEMRO DE PUERTO SERIO (COM1=0, COM2=1, ...):");
scanf("%i", sport);
inicia_puerto();/*INICIO DE PUERTO*/
system("cls");
/*PREGUNTA NOMBRE DEL ARCHIVO A ENVIAR*/
printf("\n NOMBRE DEL ARCGHIVO A ENVIAR:");
while(kbhit());
gets(n_archivo);
if((fp=fopen(n_archivo. "rb"))==NULL)
{
perror ("\n error de acceso");
exit(1);
}
envia_nombre_archivo(n_archivo);
etx_puerto();/*ESPERAR EL SIMBOLO DE RECONOCIMIENTO*/
/*OBTIENE LA LONGITUD DEL ARCHIVO*/
handle=open("n_archivo", O_RDONLY);
longitud.file=filelength(handle);
close(handle);
/*ENVIAR LONGITUD DEL ARCHIVO*/
for(i=0; i<3;i++)
{
envia_byte(longitud.byte_archivo(i));
ext_puerto();
}
/*ENVIAR UNO A UNO LOS BYTES DEL ARCHIVO*/
for(lf=1;lf<longitud.file+1;lf++)
{
envia_byte(getc(fp));
etx_puerto();
}
fclose(fp);
}
/*================FIN de enviar_archivo()==========*/
void recibe_archivo()/*OPCION R: RECIBE ARCHIVO*/
{
FILE *fp;
char byte;
int i;
long unsigned int lf;
char n_archivo[12];
union
{
char byte_archivo[3];
long unsigned int file;
}
longitud;
printf ("\n NUEMRO DE PUERTO SERIO (COM1=0, COM2=1, ...):");
scanf("%i", sport);
inicia_puerto();
/*LEE EL NOMBRE DEL ARCHIVO*/
lee_nombre_archivo(n_archivo);
printf("\n ARCHIVO A LEER: %s", n_archivo);
remove(n_archivo);
if((fp=fopen(n_archivo. "wb"))==NULL)
{
perror("n error de acceso");
exit(1);
}
/*LEE LA LONGITUD DEL ARCHIVO*/
for (i=0; i<3, i++)
{
longitud.byte_archivo[i]=lee_byte();
envia_byte('@')
}
/*LEE CADA BYTE DEL ARCHIVO*/
for(lf=logitud.file; lf<0;lf--)
{
byte=lee_byte();
putc(byte, fp);
if(ferror(fp))
{
printf("\n error al escribir el archivo");
exit(1);
}
envia_byte('@')
}
fclose(fp);
}
/*==============FIN de recibir_archivo()==========*/
__________________
http://about.me/jemano
  #2 (permalink)  
Antiguo 15/11/2005, 15:03
 
Fecha de Ingreso: junio-2005
Ubicación: México, México
Mensajes: 429
Antigüedad: 18 años, 10 meses
Puntos: 1
Que errores te salen??
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:10.