I am running this command
cat /proc/devices/memory/events/pcie0_read
in my code (c application). This is my code
#include<stdio.h>
#include<stdlib.h>
void main()
{
system(" cat /proc/devices/memory/events/pcie0_read ");
}
and the output of this command is
fidt=0x12,dtw=0x33,id=0x67
I want to extract only values from the command output using same c application.
I want to extract only 0x336712 only and save this value in an variable from the above command output.
for ex:
char var[100] or unsigned int var;
After extracting from command output I should get it,
var=0x336712
How do I do that???
popen()instead ofsystem().strtok(), first with,as delimiter, then=.awkand/orsed. Of course it is possible to extract values this way, but this can be easily implemented in C without running external programs. The declaration of the variablevaras achararray doesn't match the assignment of a hexadecimal integer value. Please edit your question and add more details what you want to do with the values. Do you need at the end a string"0xff2006"or an (unsigned)intvalue0xff2006or individual values0x06,0x02,0xff?