I wrote 2 pieces of code to examine the difference between their performance.
a.c
:
#include <stdlib.h>
#include <stdio.h>
int
main() {
char* str = "Hello\n";
FILE* fd = fopen("out.txt", "w");
for (int i=0; i<1000; i++)
fwrite(str , 1 , 100 , fd);
fclose(fd);
return 0;
}
b.c
:
#include <stdlib.h>
#include <stdio.h>
int
main() {
char* str = "Hello\n";
FILE* fd = fopen("out.txt", "w");
for (int i=0; i<1000; i++)
fwrite(str , 100 , 1 , fd);
fclose(fd);
return 0;
}
Output:
(a.riahi@asax.local@U-Riahi:cplay) > gcc a.c
(a.riahi@asax.local@U-Riahi:cplay) > time ./a.out
real 0m0.001s
user 0m0.001s
sys 0m0.000s
(a.riahi@asax.local@U-Riahi:cplay) > gcc b.c
(a.riahi@asax.local@U-Riahi:cplay) > time ./a.out
real 0m0.001s
user 0m0.000s
sys 0m0.001s
There no real difference between them.