我正在向 proc 条目写入可变数量的地址,例如
echo num_addr addr1 addr2 addr3... addr_n > /proc/memory_address
(num_addr
地址的数量在哪里),例如
echo 2 0x1100 0x3300 > /proc/memory_address
如何解析函数内部对应于 echo /proc/memory_address 的这些信息?
我正在向 proc 条目写入可变数量的地址,例如
echo num_addr addr1 addr2 addr3... addr_n > /proc/memory_address
(num_addr
地址的数量在哪里),例如
echo 2 0x1100 0x3300 > /proc/memory_address
如何解析函数内部对应于 echo /proc/memory_address 的这些信息?
#include <string.h>
#include <stdio.h>
int main()
{
char *str= "5 0x333 0x232323 555 22323 2323";
char *entptr;
int nCount;
int i;
unsigned long ulArr[5];
printf("\n String: %s", str);
nCount = strtol(str, &entptr, 10);
printf("\n NCount is %d", nCount);
printf(" Endptr = %s", entptr);
while(*entptr == ' ' || *entptr == '0' || *entptr == 'x' || *entptr == '\t') entptr++;
i = 0;
while(i<nCount)
{
str = entptr;
ulArr[i] = strtol(str, &entptr, 10);
printf("\n ulArr[%d] = %u", i, ulArr[i]);
printf(" Endptr = %s", entptr);
while(*entptr == ' ' || *entptr == '0' || *entptr == 'x' || *entptr == '\t') entptr++;
printf(" Endptr = %s", entptr);
//while(*entptr != ' ' && *entptr!='\0') entptr++;
i++;
}
return 0;
}