S
syntax
hi here is my test code
include<stdio.h>
#include<stdlib.h>
int main()
{
FILE *ptr1 = fopen("c:\\test1.txt","rb");
if(!ptr1) printf("not openedl");
int b[50];
fread(b,9,4,ptr1);
for(int k=0;k<6;k++)
printf("%d\n",b[k]);
}
test1.txt
----------
1 2 3 4 5
6 7 8 9 0
output
-------
540155953
540287027
906628405
941635360
807418144
-390643
my question > how this output is coming ? why not the output is 1 2 3
4 5
6 ?
i am not asking how can i do it .....but i am asking the explanation
why and how that garbage output is coming ? is that a garbage at all?
or have some maths behind that?
is it true that i can not use fread() to read text file? if not can u
show a code which uses fread() like above but outputing 1 2 3 4 5 6
instead of garbage ?
thanks
include<stdio.h>
#include<stdlib.h>
int main()
{
FILE *ptr1 = fopen("c:\\test1.txt","rb");
if(!ptr1) printf("not openedl");
int b[50];
fread(b,9,4,ptr1);
for(int k=0;k<6;k++)
printf("%d\n",b[k]);
}
test1.txt
----------
1 2 3 4 5
6 7 8 9 0
output
-------
540155953
540287027
906628405
941635360
807418144
-390643
my question > how this output is coming ? why not the output is 1 2 3
4 5
6 ?
i am not asking how can i do it .....but i am asking the explanation
why and how that garbage output is coming ? is that a garbage at all?
or have some maths behind that?
is it true that i can not use fread() to read text file? if not can u
show a code which uses fread() like above but outputing 1 2 3 4 5 6
instead of garbage ?
thanks