thoughts ?Code:#include <stdio.h>
#include <string.h>
#define OPEN '{'
#define CLOSE '}'
#define MAX_DEPTH 10
#define MAX_SIZE 128
char results[MAX_DEPTH][MAX_SIZE];
int lock[MAX_DEPTH];
char *data = "this is a test { to see if it works } when you nest "
"{ on different {inset values} } data { { that are nested } data }.";
int main(int args,char *argv[]) {
int spot = -1, read = 0, nest = 0;
while (++spot < strlen(data)) {
if (data[spot] == OPEN) {
nest++;
results[nest][lock[nest]++] = '~';
} else if (data[spot] == CLOSE) {
nest--;
} else {
results[nest][lock[nest]++] = data[spot];
}
}
for (int i=0; i<MAX_DEPTH; i++) printf("%s\n",results[i]);
return 0;
};