This is the echo
utility program. It reads the command-line argument from the console and prints it back to the console. In the following block of code, at line 10, why write a space to the console when there is not the end of argument string?
#include "kernel/types.h"
#include "kernel/stat.h"
#include "user/user.h"
int main(int argc, char *argv[])
{
int i;
for(i = 1; i < argc; i++){
write(1, argv[i], strlen(argv[i]));
if(i + 1 < argc){
write(1, " ", 1); //line 10
} else {
write(1, "\n", 1);
}
}
exit(0);
}