Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22228

C/C++ reverse definition [closed]

$
0
0

I have file test.txt which contains:

hwidjhcxgugdish0ikjhgy1khjkghvcgj3ihgyuhk1guijh2igkhbj2jkuigk1

And I have C header file test.h:

#define VAL1 0#define VAL2 1#define VAL3 2#define VAL4 3#define VAL5 0

I need to:

  1. for each number in test.txt (0-999) find which variable(s) in test.h have value equal to this number
  2. if this value has more than one variable - leave unchanged
  3. if only one - replace value with name of variable

In the end, the file test.txt should contain:

hwidjhcxgugdish0ikjhgyVAL2khjkghvcgjVAL4ihgyuhkVAL2guijhVAL3igkhbjVAL3jkuigkVAL2

Is it possible with sed/awk/bash/gcc/etc?


Viewing all articles
Browse latest Browse all 22228

Trending Articles