Hi!
I have this code and inside the fuction print the correct texto and numbers. Outside the function or in the main no print texto and just print a 2 big numbers.
Inside print "500 dados novos 1000"
Otside print: "2686672 2686728" and no print the texto
Someone help me please?
Thanks
Code:
#include <stdio.h>
#include <string.h>
#include <windows.h>
struct dados
{
int largura;
int velocidade;
char texto[50];
};
void escreve(struct dados val);
void ler(struct dados val);
int main()
{
struct dados entdados;
ler(entdados);
printf("%s\n",entdados.texto);
printf("%d\n",entdados.largura);
printf("%d\n",entdados.velocidade);
getchar();
getchar();
return 0;
}
void ler(struct dados val)
{
FILE* fin = fopen("c:\\castanha1.txt", "r");
fread(&val, sizeof(val), 1, fin);
fclose(fin);
printf("%d %s %d\n", val.largura, val.texto, val.velocidade);
return (void) val;
}