gpt4 book ai didi

c++ - 错误 : stray '\302' in program codeblocks

转载 作者:行者123 更新时间:2023-11-28 07:36:44 27 4
gpt4 key购买 nike

我编写了这段代码(使用代码块),我想在其中向我的手机发送 GSM 消息。它包括一些 AT 命令。问题是我在 at+cmgf=1 的 printf 中有这个错误。我认为我的代码是正确的。 UTF 或 ASCII 有问题吗?

#include <stdio.h> // standard input / output functions
#include <string.h> // string function definitions
#include <unistd.h> // UNIX standard function definitions
#include <fcntl.h> // File control definitions
#include <errno.h> // Error number definitions
#include <termios.h> // POSIX terminal control definitions


int open_port(void)
{
int fd; // file description for the serial port

fd = open("/dev/ttyAMA0", O_RDWR | O_NOCTTY | O_NDELAY);

if(fd == -1) // if open is unsucessful
{
printf("open_port: Unable to open /dev/ttyAMA0. \n");
}
else
{
fcntl(fd, F_SETFL, 0);
printf("port is open.\n");
}

return(fd);
} //open_port

int configure_port(int fd) // configure the port
{
struct termios port_settings; // structure to store the port settings in

cfsetispeed(&port_settings, B9600); // set baud rates
cfsetospeed(&port_settings, B9600);

port_settings.c_cflag &= ~PARENB; // set no parity, stop bits, data bits
port_settings.c_cflag &= ~CSTOPB;
port_settings.c_cflag &= ~CSIZE;
port_settings.c_cflag |= CS8;

tcsetattr(fd, TCSANOW, &port_settings); // apply the settings to the port
return(fd);

}
void init_gsm()
{
printf("at+cmgf=1\r\n");
printf("at+cmgs=\"60*****\"\r\n");
printf("Hello\r\n%c",26);
}
int main(void)
{
int fd = open_port();
configure_port(fd);
//query_modem(fd);
init_gsm();
return(0);

} //main

最佳答案

stray '\302' 的问题是代码在某处包含不间断空格而不是普通空格。

但是解决这个问题后,我发现了另外两个我要解决的问题 here .

关于c++ - 错误 : stray '\302' in program codeblocks,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16649105/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com