Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To LiquidBinary or any interested soul

Status
Not open for further replies.

Maulkin

Programmer
Apr 8, 2002
19
AU
thanks for the help

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.
 
#include <stdio.h>
int main()
{
char name[][6] = {&quot;One&quot;, &quot;Two&quot;, &quot;Three&quot;};
char *p1, *p2, *p3;
p1 = name[0];
p2 = name[1];
p3 = name[2];
printf(&quot;\nThe characters are %c %c %c&quot;, *p1, *p2, *p3);
return 0;
}
 
The null character (I assume this is what you mean by &quot;NULL&quot;) is a bad choice for a delimiter as this is also used to terminate strings making your array difficult to use safely with the string library functions. However, if you keep track of how many strings are placed in your array you could use strchr() in a loop to repeatedly seek to the next string.
Russ
bobbitts@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top