cs50/libcs50

GitHub: cs50/libcs50

哈佛 CS50 课程的 C 语言辅助库,为初学者提供简化的输入函数以降低学习门槛。

Stars: 2102 | Forks: 898

# CS50 C 语言库 [![构建状态](https://travis-ci.org/cs50/libcs50.svg?branch=master)](https://travis-ci.org/cs50/libcs50) ## 开发 `make`: 构建动态库 `make deb`: 构建源 deb `make install`: 默认将库安装到 `/usr/local` 下(设置 `DESTDIR` 可更改路径) ## 安装 ### Ubuntu ``` $ curl -s https://packagecloud.io/install/repositories/cs50/repo/script.deb.sh | sudo bash $ sudo apt-get install libcs50 ``` ### Fedora ``` $ curl -s https://packagecloud.io/install/repositories/cs50/repo/script.rpm.sh | sudo bash $ yum install libcs50 ``` ### 从源码安装 (Linux 和 Mac) 1. 从 https://github.com/cs50/libcs50/releases 下载最新版本 2. 解压 `libcs50-*.*` 3. `cd libcs50-*` 4. `sudo make install` 默认情况下,我们会安装到 `/usr/local`。如果你想更改安装位置,请根据需要运行 `sudo DESTDIR=/path/to/install make install`。 ## 故障排除 1. 如果在编译程序时看到 `/usr/bin/ld: cannot find -lcs50`: 将 `export LIBRARY_PATH=/usr/local/lib` 添加到你的 `.bashrc` 中。 2. 如果在编译程序时看到 `fatal error: 'cs50.h' file not found`: 将 `export C_INCLUDE_PATH=/usr/local/include` 添加到你的 `.bashrc` 中。 3. 如果在执行程序时看到 `error while loading shared libraries: libcs50.so.8: cannot open shared object file: No such file or directory`: 将 `export LD_LIBRARY_PATH=/usr/local/lib` 添加到你的 `.bashrc` 中。 关闭并重新打开所有终端窗口。 ## 用法 使用 `-lcs50` 进行链接。 ``` #include ... char c = get_char("Prompt: "); double d = get_double("Prompt: "); float f = get_float("Prompt: "); int i = get_int("Prompt: "); long l = get_long("Prompt: "); string s = get_string("Prompt: "); // deprecated as of fall 2017 long long ll = get_long_long("Prompt: "); ``` ## 文档 安装后查看 `man get_*`,或者访问 [CS50 参考手册](https://reference.cs50.net/cs50/)! ## 待办事项 * 添加测试。 ## 贡献者 * [Chad Sharp](https://github.com/crossroads1112) * [Emrul Hasan Zawad](https://github.com/ehzShelter) * [Ivan Jasenov](https://github.com/IvanJasenov) * [Kareem Zidane](https://github.com/kzidane)
标签:API密钥检测, CS50, DNS解析, get_char, get_string, MacOS, SOC Prime, 函数库, 动态链接库, 头文件, 客户端加密, 客户端加密, 库文件, 开发工具, 开源项目, 教育编程, 软件开发, 输入验证