Usage of fgets function in C

后端 未结 7 1606
野性不改
野性不改 2020-12-19 17:51

One of my assignments in to write my own UNIX Shell. To receive input from the user, I am using fgets to capture the input as a string but I\'m not really sure how it works.

相关标签:
7条回答
  • 2020-12-19 18:41

    Your string still has the newline at the end. You could compare with "exit\n" or use something like strncmp(command, "exit", 4). Note that that would accept anything that started with "exit" and ignore the rest.

    0 讨论(0)
提交回复
热议问题