diff --git a/main.c b/main.c index 25847a6..6c0ebc4 100644 --- a/main.c +++ b/main.c @@ -5,9 +5,25 @@ unsigned long strToLong(char*str) { int counter=0; char c; unsigned long val=0; + int base=10; while ((c=str[counter++])!='\0') { - val*=10; - val+=c-'0'; + if (counter==1&&c=='0') { + base=8; + continue; + } else + if (counter==2&&c=='x') { + base=16; + continue; + } + val*=base; + if (base==16&&c>='A'&&c<='F') { + val+=c-'A'+10; + } else + if (base==16&&c>='a'&&c<='f') { + val+=c-'a'+10; + } else { + val+=c-'0'; + } } return val; } @@ -16,12 +32,20 @@ int main(int argc,char**argv) { unsigned int pid; unsigned long addr; unsigned long val; - if (argc<3) { - printf("3 arguments required! Only %d specified.",argc); + unsigned int interval=1000; + if (argc<4) { + printf("3 arguments required! %d specified.",argc-1); + printf(" Format: memovr [interval (ms)]"); } else { - for (int i=1;i=5) { + interval=strToLong(argv[4]); } + printf("\nPID: %lu",pid); + printf("\nAddress: %lu",addr); + printf("\nValue: %lu",val); + printf("\nInterval: %lu",interval); } - printf("\nHello World!"); } \ No newline at end of file diff --git a/memovr b/memovr index d45ad28..be4871c 100755 Binary files a/memovr and b/memovr differ