type
status
category
date
slug
summary
tags
icon
Last edited time
May 21, 2023 07:57 AM
源起
得知在Jupyter Notebook不仅可以写python,还可以写C, C++, Java, SQL 这也太凹省了。
安装C语言内核:jupyter-c-kernel
终端键入

在VS Code测试
VS Code现在版本自带插件Jupyter
直接新建一个ipynb文件试试

点击右上角,把kernel改成C

新建一个Cell,运行成功

在Anaconda测试
遇到问题

原因是,之前安装jupyter-c-kernel不是在anaconda的环境下
解决方案
很简单,切换到conda环境下,重新执行那两条命令就可以了

成功

一个问题,input /scanf(”%d”, &n); 仍未解决
测试了一下,如果使用C的scanf进行输入的话,无论在VS Code还是Anaconda,都无法正常输入

VS Code一直等待输入,卡住

上GitHub查了下ISSUE,发现也有相同问题
scanf("%d“, &c);
Updated Jan 23, 2024
Input command like scanf(()and getchar() can not work
Updated Feb 25, 2021
找到回复,这个问题还没有被解决
那我只好recommended use with Docker试试
jupyter-c-kernel
brendan-rius • Updated Jan 12, 2025

事实证明,并不行。
SO,目前输入只能靠赋值来使用了。
参考资料
jupyter-c-kernel
brendan-rius • Updated Jan 12, 2025
- 作者:Jimmy Huang
- 链接:https://huangjihao.com/80c303e3-8b72-4fc1-8eeb-e411bfa48b0c
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。