Hi,
Can anyone tell me why the second printf returns the sizeof(record) as 4 whereas the first returns 10 as I would expect?
Thanks
#include <stdio.h>
#include <string.h>
void read_input(FILE *ifile, char *record);
main(){
FILE *ifile;
char record[10+1];
if((ifile=fopen("input.dat","r")==NULL)
{
printf("Input file not found\n"
}
printf("record length is %d\n", sizeof(record));
read_input(ifile, record);
}
void read_input(FILE *ifile, char *record){
fread(record,1,sizeof(record), ifile);
printf("record length is %d\n", sizeof(record));
}
Can anyone tell me why the second printf returns the sizeof(record) as 4 whereas the first returns 10 as I would expect?
Thanks
#include <stdio.h>
#include <string.h>
void read_input(FILE *ifile, char *record);
main(){
FILE *ifile;
char record[10+1];
if((ifile=fopen("input.dat","r")==NULL)
{
printf("Input file not found\n"
}
printf("record length is %d\n", sizeof(record));
read_input(ifile, record);
}
void read_input(FILE *ifile, char *record){
fread(record,1,sizeof(record), ifile);
printf("record length is %d\n", sizeof(record));
}