I'm a newbie in C so please excuse some of my mistakes. I'm wondering if there is a possible way to store multiple string/array values in one string? Here is an example to give you an idea of what I am trying to do.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
const char *lister[] = {"H", "E", "LL", "O"}; //forgot brackets, fixed now
int main()
{
char *mystring[] = ("%s%s", lister[1], lister[2]);
printf ("%s\n", mystring);
return 0;
}
Not sure if that makes any sense at all, but looking for ways to store string values into another string or array. Thanks! :) EDIT: strncat fixes this problem, if you encountered the same problem then go to http://www.tutorialspoint.com/c_standard_library/c_function_strncat.htm to learn more, thanks to computerfreaker for suggesting strncat!
strcatorstrncat. Both functions append (conCATenate) one string to another.strcatappends one entire string to another;strncatis slightly safer because you specify the number of characters from the second string to append to the first.char multistring[] = "one\0two\0three"; printf("%s, %s, %s\n", multistring, multistring + 4, multistring + 8);