ld: warning: ignoring file file, file was built for unsupported file format ( 0x70 0x6F 0x6A 0x61 0x0A 0x6F 0x64 0x6F 0x64 0x6F 0x6B 0x64 0x6F 0x6B 0x64 0x6F ) which is not the architecture being linked (x86_64): file
这是编译程序后的错误。在我的程序中,我想在一个名为file
的文件上打印80个字符。
这是我的计划:
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
void print_80_char(char *path)
{
int i;
int fd;
char *buf;
fd = open(path, O_RDWR);
buf = malloc(sizeof(char) * 80);
i = 0;
while (buf[i] <= 79)
{
read(fd, buf, 80);
printf("%c", buf[i]);
i++;
}
}
我的主要是:
#include <stdlib.h>
void print_80_char(char *path);
int main()
{
print_80_char("file");
return 0;
}