18-11-2014, 22:51
HOLA!!! Este codigo no me compila y no entiendo que es lo que tengo que corregir. Me podrian ayudar??? Gracias. Uso codeblocks
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#define n 100
struct registro
{
int codigo;
int medicion;
char descripcion[20];
}
var_registro, p_registro, ae_registro[n];
int main()
{
char tecla, caracter;
FILE *p_lectura_t, *p_escritura_t, *p_lectura_w, *p_escritura_w;
p_lectura_t = fopen("datos1.txt","r");
if (p_lectura_t == NULL)
{
printf("Error al leer el archivo datos1.txt. \n");
printf("Saliendo de la aplicacion...\n");
tecla=getchar();
return(1);
}
p_escritura_t = fopen("datos1.bak","w");
if (p_lectura_t == NULL)
{
printf("Error al leer el archivo datos1.bak. \n");
printf("Saliendo de la aplicacion...\n");
getchar();
return(1);
}
}
caracter = fgetc(p_lectura_t);
while (feof(p_lectura_t)==0)
{
printf("%c",caracter);
fputc(caracter,p_escritura_t);
caracter = fgetc(p_lectura_t);
}
fclose(p_lectura_t);
fclose(p_escritura_t);
LOS ERRORES SON:
In function 'main'
|19|warning: variable 'p_escritura_t' set but not used [-Wunused-but-set-variable]
|18|warning: unused variable 'caracter' [-Wunused-variable]
|18|warning: variable 'tecla' set but not used [-Wunused-but-set-variable]
|39|warning: data definition has no type or storage class [enabled by default]
|39|warning: type defaults to 'int' in declaration of 'caracter' [-Wimplicit-int]
|39|error: 'p_lectura_t' undeclared here (not in a function)
|40|error: expected identifier or '(' before 'while'
|47|warning: data definition has no type or storage class [enabled by default]
|47|warning: type defaults to 'int' in declaration of 'fclose' [-Wimplicit-int]
|47|warning: parameter names (without types) in function declaration [enabled by default]
|48|warning: data definition has no type or storage class [enabled by default]
|48|warning: type defaults to 'int' in declaration of 'fclose' [-Wimplicit-int]
|48|warning: parameter names (without types) in function declaration [enabled by default]|In function 'main':
|38|warning: control reaches end of non-void function [-Wreturn-type]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#define n 100
struct registro
{
int codigo;
int medicion;
char descripcion[20];
}
var_registro, p_registro, ae_registro[n];
int main()
{
char tecla, caracter;
FILE *p_lectura_t, *p_escritura_t, *p_lectura_w, *p_escritura_w;
p_lectura_t = fopen("datos1.txt","r");
if (p_lectura_t == NULL)
{
printf("Error al leer el archivo datos1.txt. \n");
printf("Saliendo de la aplicacion...\n");
tecla=getchar();
return(1);
}
p_escritura_t = fopen("datos1.bak","w");
if (p_lectura_t == NULL)
{
printf("Error al leer el archivo datos1.bak. \n");
printf("Saliendo de la aplicacion...\n");
getchar();
return(1);
}
}
caracter = fgetc(p_lectura_t);
while (feof(p_lectura_t)==0)
{
printf("%c",caracter);
fputc(caracter,p_escritura_t);
caracter = fgetc(p_lectura_t);
}
fclose(p_lectura_t);
fclose(p_escritura_t);
LOS ERRORES SON:
In function 'main'
|19|warning: variable 'p_escritura_t' set but not used [-Wunused-but-set-variable]
|18|warning: unused variable 'caracter' [-Wunused-variable]
|18|warning: variable 'tecla' set but not used [-Wunused-but-set-variable]
|39|warning: data definition has no type or storage class [enabled by default]
|39|warning: type defaults to 'int' in declaration of 'caracter' [-Wimplicit-int]
|39|error: 'p_lectura_t' undeclared here (not in a function)
|40|error: expected identifier or '(' before 'while'
|47|warning: data definition has no type or storage class [enabled by default]
|47|warning: type defaults to 'int' in declaration of 'fclose' [-Wimplicit-int]
|47|warning: parameter names (without types) in function declaration [enabled by default]
|48|warning: data definition has no type or storage class [enabled by default]
|48|warning: type defaults to 'int' in declaration of 'fclose' [-Wimplicit-int]
|48|warning: parameter names (without types) in function declaration [enabled by default]|In function 'main':
|38|warning: control reaches end of non-void function [-Wreturn-type]