-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add sasa.c #15
base: master
Are you sure you want to change the base?
add sasa.c #15
Conversation
int fdescript; | ||
ssize_t readbytes; | ||
ssize_t writebytes; | ||
char buf[1024]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1024
みたいなマジックナンバーはstatic const
か#define
にしたいね
|
||
int main(int argc, char * argv[]){ | ||
int fdescript; | ||
ssize_t readbytes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
どうでもいいけどタブとスペースが混ざっている気がする
fdescript = open(argv[i], O_RDONLY); | ||
if (fdescript == -1) | ||
continue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
インデントが揃っていなくてわかりにくいけど、"引数を複数指定したら最初に開けたファイルを出力する"という仕様になっているっぽい?
オリジナルのcatの仕様(となぜcatという名前がついているか)を確認してみるといいかも
writebytes = write(1,buf,readbytes); | ||
} else if (readbytes == 0) { | ||
close(fdescript); | ||
writebytes = write(1,"\n",1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
writebytes
は代入しているけど使っていないのかな?
書き込み失敗した時のエラーハンドリングもしたいところですね
No description provided.