我想用C程序验证我的设备的序列号,所以获取序列号的命令在shell中:
dd if=/dev/mtd0 bs=1 skip=$((0x1fc30)) count=16 2>/dev/null
这将产生如下结果:
1866203214226041
这基本上就是我想要做的事情:
#include <stdio.h>
#include <string.h>
int main ()
{
int sn;
sn=1866203214226041;
system("dd if=/dev/mtd0 bs=1 skip=$((0x1fc30)) count=16 2>/dev/null");
if (output of system == sn) {
printf("The serial number is verified\n");
}
else {
printf("The serial number is not verified\n");
}
return(0);
}
我该怎么做?