I hope the title of my question is correct.
I have a stringpool
char **string_pool;
that gets initiated in a function like
string_pool = malloc( sizeof(char *) * 1024);
i get strings from stdin and scanf them into the array
scanf("%[^\n]s", &string_pool[index]);
so i can print it out using printf
printf("gets %s\n", &string_pool[index]);
how can i
Thank you
Edit
Maybe i should explain it a bit more, its a virtual machine with a virtual instruction set and a program like
push 1 read gets
should :
the functions looks like
case GETS: { int index = popv(); // index is already on top of the stack int strl = strlen(&string_pool[index]);printf("gets %s with a length of %d\n", &string_pool[index], strl); // pseudo code // push each char as integer on the stack foreach(char in string_pool[index]) push((int)char); break; } case READ: { int index = popv(); scanf("%[^\n]s", &string_pool[index]); break; } case WRITE: { int index = popv(); printf("%s", &string_pool[index]); break; }
My problem is in the GETS case. I want to push every char as int onto the stack.
#c #arrays #string