所以,我已经给了远程服务器多余的东西,我通过/ opt目录中的ssh复制了我的文件。当我编译我的代码时,它没有错误,但是当我使用
运行a.out时public interface FooApi {
FooDelegate getDelegate();
@ApiOperation(value = "", nickname = "fooAction", notes = "", response = String.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = String.class)
})
@RequestMapping(value = "/fooAction",
produces = { "text/plain" },
method = RequestMethod.GET)
default ResponseEntity<String> fooAction(HttpServletRequest request) {
return getDelegate().fooAction(request);
}
}
它输出奇怪的字符集,如下所示: -
./a.out
目录中有两个c源文件,当我使用
时�gjx�}|_�]�������D���"�%
一个文件成功运行,但另一个文件没有运行。 我也尝试过:
$stty sane
$tput clear
如果您需要查看我将提供的终端,它不起作用。我真的不明白我该怎么做。
我的代码:
Ctrl+C
reset
修改
评论#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
static uint32_t map_size = 0x08000000;
static uint32_t map_base = 0x18000000;
static uint32_t map_addr = 0x00000000;
static char *dev_mem = "/dev/mem";
int main(int argc, char **argv) {
int fd;
uint32_t *buf;
if ((fd = open(dev_mem, O_RDWR | O_SYNC)) == -1) {
printf("can't open /dev/mem .\n");
exit(EXIT_FAILURE);
}
buf = mmap((uint32_t *) map_addr, map_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, map_base);
if (buf == (void *) -1) {
printf("Can't be mapped. \n");
exit(EXIT_FAILURE);
}
else
map_addr = (long unsigned) buf;
fwrite(buf, 1, map_size, stdout);
// Fletcher's 32 bit checksum algorithm
uint32_t sum1 = 0xffff, sum2 = 0xffff;
uint32_t tempLen;
while (map_size) {
tempLen = map_size >= 359 ? 359 : map_size;
map_size -= tempLen;
do {
sum2 += sum1 += *buf++;
} while (--tempLen);
sum1 = (sum2 & 0xffff) + (sum1 >> 16);
sum2 = (sum2 & 0xffff) + (sum2 >> 16);
}
sum1 = (sum1 & 0xffff) + (sum1 >> 16);
sum2 = (sum2 & 0xffff) + (sum2 >> 16);
uint32_t sum = sum2 << 16 | sum1;
printf("%u", sum);
close(fd);
return 0;
}
后
终端没有打印奇怪的字符,但现在我认为它应该是sum fwrite(buf, 1, map_size, stdout);
的打印值,它不会这样做,而是现在我在运行uint32_t sum = sum2 << 16 | sum1;
<时收到此消息/ p>
time ./a.out
答案 0 :(得分:1)
map_size
以字节为单位,但uint32_t buf
表示*buf++
每次前进4个字节,直到缓冲区溢出且代码段错误为止。
注意:您有各种类型和强制转换错误导致代码无法移植。