我正在尝试使用wiringPi的简单代码:
#include<wiringPi.h>
#include<stdio.h>
int main(void){
int i;
wirintPiSetup();
pinMode(0,OUTPUT); //a single LED
pinMode(8,INPUT); //tactile switch
for(;;){
delay(500);
//push tactile switch and LED is turning on
if(digitalRead(8)) digitalWrite(0,0);
else digitalWrite(0,1);
printf("%d",digitalRead(8));
}
}
Run Code Online (Sandbox Code Playgroud)
我期望printf()的结果输出到控制台,但它不起作用.printf()无法与wiringPi API同时运行?
编译时没有警告.并且CPU消耗总是低于4%.在Raspbian上运行.
谢谢你的时间!
from socket import *
from threading import Thread
udp_socket = None
dest_ip = ''
dest_port = 0
def send():
while True:
content = input('<<<')
udp_socket.sendto(content.encode(), (dest_ip, dest_port))
def recv():
while True:
data = udp_socket.recvfrom(1024)
content, address = data
ip, port = address
print('\r>>>[%s %d] %s' % (ip, port, content.decode()))
print('<<<', end='')
def main():
global udp_socket, dest_ip, dest_port
udp_socket = socket(AF_INET, SOCK_DGRAM)
udp_socket.bind(('', 7788))
dest_ip = input('Please enter the IP: ')
dest_port = int(input('Please enter the port: '))
ts = Thread(target=send) …Run Code Online (Sandbox Code Playgroud) printf()C 中的函数\n最后是否需要 a才能工作?
我尝试打印出一个最后没有换行符的简单语句,但没有奏效。
谢谢。
像这样的东西,我想看到完整的语法.
伪代码:
var = user_input
if var > 5:
output = 'var > 5'
else:
output = 'var < 5'
Run Code Online (Sandbox Code Playgroud) 我知道我发布的程序非常基本,但我无法找到错误.我重新检查了一切,但尽管没有编译错误,输出也没有到来.
#include<stdio.h>
#include <stdlib.h>
int main()
{
int i;
while(1)
{
if((scanf("%d",&i))!=42)
{
printf("%d",i);
}
else
{
break;
}
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
感谢您的时间和考虑.
这是代码,它是C代码.并请说明="字符串"的返回值
char * p = (char*) malloc(sizeof(char) * 100);
p = "hello";
*(p+1) = '1';
printf("%s", p);
free(p);
Run Code Online (Sandbox Code Playgroud) c ×5
printf ×2
buffering ×1
gpio ×1
io ×1
newline ×1
printing ×1
python ×1
python-3.x ×1
raspberry-pi ×1