this will not work in my problem my string array ispopulated by a loop and looks like this if input strings are "one" "two" "three"
on the first pass the array will contain
oneNULL
on the second
oneNULLtwoNULL
on the third
oneNULLtwoNULLthreeNULL I need the pointers to point to the
O in One the T in Two and the T in Three
is this possible.
I too need to create array of pointers.
char* aOfs[]={ "One",
"Two",
"Three",
"Four",
"Five"
};
In the above declaration, I don't have ELEMS as it was. So i don't know the total strings in the array. I need to point each one of those strings and display the two strings on the LCD two at the time.
To be able to do what you want to do you will need an index for your array,you might use "#define ELEMS 5" like in the previous example or something like "const int ELEMS = 5".But without an index you wont be able to achieve it.
let say that you have one,now to print the strings two at the time,you could use this:
int i = 0;
while( i < ELEMS )
{
if( i < ELEMS - 1 )
{
printf("%s",aOfs[i++]);
printf(" %s\n",aOfs[i++]);
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.