微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么我的 C++ 程序在我接受字符串输入后立即终止?

如何解决为什么我的 C++ 程序在我接受字符串输入后立即终止?

我正在尝试从用户“上午 11 点 59 分”处获取时间输入,但一旦我提供输入,它就会终止。

'p' 的输入格式为 11:59 AM,'s' 的输入格式为 10:00 AM 11:00 AM

user@user-VirtualBox:/media/sf_shared_folder$ make hello
cc     hello.c   -o hello
hello.c: In function ‘init_module’:
hello.c:11:4: warning: implicit declaration of function ‘printk’ [-Wimplicit-function-declaration]
   11 |    printk(KERN_INFO "Hello,user!\n");
      |    ^~~~~~
hello.c:11:11: error: ‘KERN_INFO’ undeclared (first use in this function)
   11 |    printk(KERN_INFO "Hello,user!\n");
      |           ^~~~~~~~~
hello.c:11:11: note: each undeclared identifier is reported only once for each function it appears in
hello.c:11:20: error: expected ‘)’ before string constant
   11 |    printk(KERN_INFO "Hello,user!\n");
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                    )
hello.c: In function ‘cleanup_module’:
hello.c:17:11: error: ‘KERN_INFO’ undeclared (first use in this function)
   17 |    printk(KERN_INFO "Goodbye,user!\n");
      |           ^~~~~~~~~
hello.c:17:20: error: expected ‘)’ before string constant
   17 |    printk(KERN_INFO "Goodbye,user!\n");
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                    )
hello.c: At top level:
hello.c:21:16: error: expected declaration specifiers or ‘...’ before string constant
   21 | MODULE_LICENSE("GPL");
      |                ^~~~~
hello.c:22:20: error: expected declaration specifiers or ‘...’ before string constant
   22 | MODULE_DESCRIPTION("My first cool kernel module");
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hello.c:23:15: error: expected declaration specifiers or ‘...’ before string constant
   23 | MODULE_AUTHOR("user");
      |               ^~~~~~~~~~~~~
make: *** [<builtin>: hello] Error 1

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。