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!

redeferencing pointers to strings-what am I doing wrong?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
If I have an array of pointers to an array of strings and I want to redereference pointers,so that the pointer with lowest index will point to smallest string.I know two ways of doing this and one way gives me strange results and for the life of me I don't know why.

for(int j=0;j<10-1;j++)
{
int i=a;
for(;i<10;i++)
{
if(*pwords[j]>word)
{
pwords[j]=&word;
pwords=&word[j];
}
}
}
Why isn't this also the right way?I know there is an alternative to this by assigning adresses of pointers to pointers,but I want to know what is wrong with this code.I might write a very short text and it will output words in ascending order(which is supposed to do),but other times it will ignore some words when outputting it or it will repeat one word more then once).I sure hope someone can help me!

Thank you
 
You have sent not enough code. But some questions I would ask.
How are word[] and pwords[] declared and initialized?
What does 'i' (You use 'j' only)? What is a?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top