Read a string char by char from an associative pointer array

Read a string char by char from an associative pointer array

I hope the title of my question is correct.

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

  • get the length of string_pool[index]
  • read string_pool[index] char by char in a loop

Thank you


Maybe i should explain it a bit more, its a virtual machine with a virtual instruction set and a program like

push 1

should :

  • push 1 on the stack -> let x be 1
  • read stdin as string into string_pool[x]
  • push all characters onto the stack

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);


case READ: {  
    int index = popv();          
    scanf("%[^\n]s", &string_pool[index]);

case WRITE: {  
    int index = popv();          
    printf("%s", &string_pool[index]);

My problem is in the GETS case. I want to push every char as int onto the stack.

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Learn C ++ From Scratch (2 Strings, Vectors, and Arrays)

It can be said that string and vector are the two most important types in the C++ standard library. String supports variable-length strings, and vector represents a variable-length collection.

Increased array size. after increaseSize function some arguments of the same array are invalid. C lang

The program takes some txt input from "numbers.txt" file. It first counts the&nbsp;<strong><em>amount</em></strong>&nbsp;of all the numbers (freqCount)in that text file, than reads the file again and with the use of malloc it creates two arrays A and B , of which both have size equal to the&nbsp;<strong>amount</strong>&nbsp;of all the numbers in the text file. So far so good.