I am trying to take string user input from the user using c code and then add it to array of strings so that I could have a variable its first component be a word so if the variable called X then X[1] becomes full word which inputted to the array using prompt function like getstring but when I tried the code below it gave me error.
Can anyone help me restructure my code ?
#include <stdio.h>
#include "cs50.h"
#include <string.h>
string get_items();
bool check_items_add = true;
int main()
{
string units = get_items();
printf("%s\n", units[1]);
}
string get_items()
{
string items[] = get_string("Write market item: ");
while (check_items_add)
{
items += get_string("Write market item: ");
}
return items;
}