When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
24 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
im confused as to why the strcmp statement goes through if previous and current both point to the same place, with the condition being if theyre NOT the same
strcmp does a alpha sort of chars.. <0 means arg1 was less then arg2 (alphabetically)
yes!! but i dont understand the previous part, where it says if(current != previous)... bc i set previous and current both to the head prior to the dowhile loop
if current == previous, then that if() never runs it's body
yes but why! since theyre both pointing to the same place?
like if head was "name"
theyre both pointing to name, so how could they be different?
you have two "name"'s ?!
what is your actual C++ syntax question ?
or are you asking why your algo doesn't work?
it works! im just confused abt why it does-- let me write my question visually to better explain
cout << uintptr_t(current)
know you know how to output ptr values.
does that help?!
cout << current->data.name; now you can display the content of that..
do that pre-strcmp.. now you can see what is about to occur
cout << uintptr_t(current) and cout << uintptr_t(previous) just before that if
if *current and previous
prove it
that didnt help bc theyre the same numbers
im not very good at pointers and nodes yet, so im just wondering how it differentiates between them, and why they wouldnt be the same thing.
are you claiming that ptr1 with a value of (lets say) 100, and ptr2 with the same value correctly executes if( ptr1 != ptr2 ) ? cause that would make most of the software in the world be wrong.
i have no idea but thats alright i just do not think i will understand this way. ill just figure it out another time after more research
!solved
Thank you and let us know if you have any more questions!