读取输入的txt文件并用c格式化

读取输入的txt文件并用c格式化,c,text,input,format,C,Text,Input,Format,我有一个输入文件,每行有不同的内容和长度。 每行代表一个命令 in cr foo //create file "foo" op foo //open it with index 1 wr 1 x 60 //write x in index 1("foo") 60 times wr 1 y 10 //write y in index 1("foo") 60 times sk 1 55 //such and such... rd 1 10 dr sv disk0.txt i

我有一个输入文件,每行有不同的内容和长度。 每行代表一个命令

in
cr foo   //create file "foo"
op foo   //open it with index 1
wr 1 x 60   //write x in index 1("foo") 60 times
wr 1 y 10   //write y in index 1("foo") 60 times
sk 1 55     //such and such...
rd 1 10
dr
sv disk0.txt

in disk0.txt
op foo
rd 1 3
cr foo
cl 1
dr
我已经看了这个答案,但它对我的问题仍然没有帮助。 我真的需要帮助如何正确读取这个输入文件,以便执行不同的命令。 这个命令可能包含整数,或者它只有一个字符,我不知道如何处理这个文本!请帮忙

  • 使用
    fgets()
    阅读到行尾
  • 请指出,
    fgets()
    带有新行字符
  • 使用空格作为分隔符的
    strtok()
    将行中断为令牌
  • 相应地使用代币
  • 使用
    strtol()
    处理整数
  • 使用
    fgets()
    阅读到行尾
  • 请指出,
    fgets()
    带有新行字符
  • 使用空格作为分隔符的
    strtok()
    将行中断为令牌
  • 相应地使用代币
  • 使用
    strtol()
    处理整数
  • 使用
    fgets()
    阅读到行尾
  • 请指出,
    fgets()
    带有新行字符
  • 使用空格作为分隔符的
    strtok()
    将行中断为令牌
  • 相应地使用代币
  • 使用
    strtol()
    处理整数
  • 使用
    fgets()
    阅读到行尾
  • 请指出,
    fgets()
    带有新行字符
  • 使用空格作为分隔符的
    strtok()
    将行中断为令牌
  • 相应地使用代币
  • 使用
    strtol()
    处理整数

  • 您知道命令中可以显示的最大字数是多少吗?您知道命令中可以显示的最大字数是多少吗?您知道命令中可以显示的最大字数是多少吗?您知道命令中可以显示的最大字数是多少吗?