当前位置:网站首页>树莓派assert初步使用练习
树莓派assert初步使用练习
2022-06-23 03:58:00 【m0_52487771】
一、创建用户
用户密码
sudo useradd -m 用户名
sudo passwd 用户名
给予用户sudo权限
#切换到root用户
su
#编辑配置文件
vi /etc/sudoers
#增加配置(按i开始编辑,Esc退出编辑,:wq!保存强制退出), 在打开的配置文件中,找到root ALL=(ALL) ALL, 在下面添加一行
#其中xxx是你要加入的用户名称
xxx ALL=(ALL) ALL
二、简单C程序
创建一个C程序
#include <assert.h>
#include <stdio.h>
int main()
{
int a;
char str[50];
printf("请输入一个整数值: ");
scanf("%d", &a);
assert(a >= 10);
printf("输入的整数是: %d\n", a);
printf("请输入字符串: ");
scanf("%s", str);
assert(str != NULL);
printf("输入的字符串是: %s\n", str);
return(0);
}
按ESC,然后输入wq,编译
编译命令行:gcc 程序名.c -o 程序名
三、assert()
简介
C 标准库的 assert.h头文件提供了一个名为 assert 的宏,它可用于验证程序做出的假设,并在假设为假时输出诊断消息。
库宏
assert.h头文件定义了唯一的函数:assert()
void assert(int expression) 这实际上是一个宏,不是一个函数,可用于在 C 程序中添加诊断。
C 库宏 - assert()
描述:C 库宏 void assert(int expression) 允许诊断信息被写入到标准错误文件中。换句话说,它可用于在 C 程序中添加诊断。
声明:void assert(int expression);
expression :这可以是一个变量或任何 C 表达式。如果 expression 为 TRUE,assert() 不执行任何动作。如果 expression 为 FALSE,assert() 会在标准错误 stderr 上显示错误消息,并中止程序执行。
返回值:无
例子
#include <assert.h>
#include <stdio.h>
int main()
{
int a;
char str[50];
printf("请输入一个整数值: ");
scanf("%d", &a);
assert(a >= 10);
printf("输入的整数是: %d\n", a);
printf("请输入字符串: ");
scanf("%s", str);
assert(str != NULL);
printf("输入的字符串是: %s\n", str);
return(0);
}

四、不同Linux系统之间文件传输
这次是在Ubuntu系统与树莓派系统之间文件传输
用到scp命令
Linux scp 命令用于 Linux 之间复制文件和目录。
scp 是 secure copy 的缩写, scp 是 linux 系统下基于 ssh 登陆进行安全的远程文件拷贝命令。
scp 是加密的,rcp 是不加密的,scp 是 rcp 的加强版。
使用方法
scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
[-l limit] [-o ssh_option] [-P port] [-S program]
[[[email protected]]host1:]file1 [...] [[[email protected]]host2:]file2
如下`
`scp local_file [email protected]_ip:remote_folder
或者
scp local_file [email protected]_ip:remote_file
或者
scp local_file remote_ip:remote_folder
或者
scp local_file remote_ip:remote_file
这个能从本地复制到远程
边栏推荐
- Jsonfield annotation in fastjson
- Jenkins installs and deploys and automatically builds and publishes jar applications
- Onnxoptimizer, onnxsim usage records
- [microservices | Nacos] list of issues related to the Nacos version
- 关于DOS/DDOS攻击和防御
- MDM数据清洗功能开发说明
- 架构师之路,从「存储选型」起步
- [leetcode] longest increasing subsequence problem and its application
- Cloud native architecture (04) -cncf
- Win11 app store keeps turning around solution
猜你喜欢

GO语言-panic和recover

STC 32位8051单片机开发实例教程 一 开发环境搭建

MCS: continuous random variable - student's t distribution

51万奖池邀你参战——第二届阿里云ECS CloudBuild开发者大赛来袭

The road of architects starts from "storage selection"

Introduction to JDBC (I) DML operation

Array The from method creates an undefined array of length n
![[opencv450] inter frame difference method](/img/ad/c8a56e27d78cea581deb1874620613.png)
[opencv450] inter frame difference method

Mathematical analysis_ Notes_ Chapter 1: set and mapping

JVM原理之内存模型
随机推荐
Webrtc[47] - a common way for webrtc to save YUV data
Export PDF with watermark
云原生大趋势下的容器化技术现状与发展
pygame音乐相关的功能实现
MCS: discrete random variable
CF【1700D】D. River Locks(dp、二分、数学)
抽奖 ddd 代码
Complete one-time GC process of JVM principle
Pkav simple blasting
1010 Radix
markdown给图片加背景色
IP6809三线圈15W无线充电发射端方案ic英集芯
Array The from method creates an undefined array of length n
CF [1700d] D. River locks (DP, bisection, Mathematics)
ES6的Array.from方法创建长度为N的undefined数组
Introduction to JDBC (IV) - use of Druid connection pool
LeetCode-1757. 可回收且低脂的产品_SQL
Spark 离线开发框架设计与实现
Onnxoptimizer, onnxsim usage records
MCS: continuous random variable chi square distribution