String concation problem


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: String concation problem

  1. #1
    Join Date
    Aug 2008
    Posts
    1

    String concation problem

    hay
    /////Code is////////////////////////////////////////////////////
    Code:
    AP_List * AP_List_SJ( )
    {
    	AP_List *New_AP_List_Object = new AP_List();
    	AP_Node * Temp,*Temp2;
    	string Value="",Final_Value="";
    	int count=0;
    	
    	Temp = Temp2 = Head_AP_Node->Get_Next();
    
    	while ( Temp != NULL )
    	{
    		while ( Temp2 != NULL )
    		{
    			if ( Matched_String( Temp->Get_Value(),Temp2->Get_Value() ) == false )
    			{
    				Value="",Final_Value="";
    				Value = Temp->Get_Value();
    				Final_Value = Value;
    				Final_Value.append("~");
    				
    				Value = Temp2->Get_Value();
    				Final_Value += Value;
    
    
    				New_AP_List_Object->Insert_AP_Node(Final_Value);
    				count++;
    
    			}
    			Temp2=Temp2->Get_Next();
    		}
    		Temp = Temp->Get_Next();
    		Temp2=Head_AP_Node->Get_Next();
    
    	}
    
    	return New_AP_List_Object;
    }
    //////////////////////////////////////////////////////////////////


    The problem is when it is called in first iteration with list as

    head->Rice->Wheat->Beans

    it gives right output

    head->Rice~Wheat->Rice~Beans->Wheat~Beans

    but when it is called in second iteration with

    head->Rice~Wheat->Rice~Beans->Wheat~Beans

    it gives output

    head->Rice~Wheat->Rice~Beans->Wheat~Beans

    instead of head->Rice~Wheat~Rice~Beans->Rice~Beans~Wheat~Beans-> and so on

    please tell where the bug is
    Last edited by Hack; 08-29-2008 at 08:19 AM. Reason: Added Code Tags

  2. #2
    Join Date
    May 2007
    Posts
    843
    Logic problem.

Similar Threads

  1. string array in c++
    By emeric in forum C++
    Replies: 11
    Last Post: 07-16-2007, 10:36 PM
  2. Create a vCard
    By admol in forum .NET
    Replies: 0
    Last Post: 02-27-2007, 11:30 AM
  3. Problem When Retrieve SmartCard from VB 6
    By tekidum in forum VB Classic
    Replies: 0
    Last Post: 09-09-2006, 03:08 AM
  4. Input string was not in a correct format
    By mdengler in forum ASP.NET
    Replies: 0
    Last Post: 11-26-2002, 03:32 PM
  5. How do I detect an FTP timeout?
    By Julian Milano in forum VB Classic
    Replies: 0
    Last Post: 08-10-2000, 10:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center