B
broli
I wrote a simple program that copies input to output but this is done
by using fread and fwrite.
#include<stdio.h>
int main(void)
{
FILE *fp;
int foo[10];
int a[10];
fread(a, sizeof(int), 10, stdin);
fwrite(a, sizeof(int), 10, stdout);
return 0;
}
Here's my input(Consecutive ints separated by a single space)
1 2 3 4 5 6 7 8 9 10
The output (as I expected)
1 2 3 4 5 6 7 8 9 10
When consecutive ints are separated by tabs -
i/p
1(TAB)2(TAB)3(TAB)4(TAB)5(TAB)6(TAB)7(TAB)8(TAB)9(TAB)10
o/p
1(TAB)2(TAB)3(TAB)4(TAB)5(TAB)6(TAB)7(TAB)8(TAB)9(TAB)10
^^ Can anyone explain why this happened ??
Also when consecutive ints are seperated by inconsistent blank spaces
1 2 3 4 5 6 7 8 9 10
then o/p is
1 2 3 4 5 6 7
or 1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 1
by using fread and fwrite.
#include<stdio.h>
int main(void)
{
FILE *fp;
int foo[10];
int a[10];
fread(a, sizeof(int), 10, stdin);
fwrite(a, sizeof(int), 10, stdout);
return 0;
}
Here's my input(Consecutive ints separated by a single space)
1 2 3 4 5 6 7 8 9 10
The output (as I expected)
1 2 3 4 5 6 7 8 9 10
When consecutive ints are separated by tabs -
i/p
1(TAB)2(TAB)3(TAB)4(TAB)5(TAB)6(TAB)7(TAB)8(TAB)9(TAB)10
o/p
1(TAB)2(TAB)3(TAB)4(TAB)5(TAB)6(TAB)7(TAB)8(TAB)9(TAB)10
^^ Can anyone explain why this happened ??
Also when consecutive ints are seperated by inconsistent blank spaces
1 2 3 4 5 6 7 8 9 10
then o/p is
1 2 3 4 5 6 7
or 1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 1