Start New Discussion within our Software Development Community
void SubGen(char* s)
{  //rearrange s ...
	 
	for(int i=0;i<strlen(s);i++)
	{
		 for(int j=i+1;j<strlen(s);j++)
		 {
			   if(s[i]==s[j])
			   { char temp=s[i+1];
			      s[i+1]=s[j];
				  s[j]=temp;
			   }
		 }
	}
	//s arranged....
    
	Sub[0][0].push_back(s[0]);
	for(int i=1;i<strlen(s);i++)
	{
		 if(s[i]==s[i-1])
		 {  vector<string> temp;
			           for(int j=i-1;j<Sub.size();j++)
		                 	 {   for(int p=0;p<Sub[j].size();p++)
		                    	         {
                                              temp.push_back(Sub[j][p]);
                   		     	          }
					         }
					   	 for(int j=0;j<temp.size();j++)
			                 {
								 temp[j].push_back(s[i]);
			                  }
		                   	 

			 Sub.push_back(temp);
		 } 

		 else
		 {  vector<string> temp;
			 for(int j=0;j<Sub.size();j++)
		                 	 {   for(int p=0;p<Sub[j].size();p++)
			                             {
                                             temp.push_back(Sub[j][p]);
			                              }
			                 }
			 for(int j=0;j<temp.size();j++)
			                 {
								 temp[j].push_back(s[i]);
			                  }

			 Sub.push_back(temp);

		 }



			  

		 
	}  //for close..

	
	for(int i=0;i<Sub.size();i++)
	{
		 for(int j=0;j<Sub[i].size();j++)
		    {   
				  SF.push_back(Sub[i][j]);     //SF final subset of string input....
		    }
	}
				  

}

The above is the code for generating subsets of a given string.Global declarations are
vector<vector<string> > Sub;
vector<string> SF;

The code works properly and I am able to get the subsets in SF.But I am not able to access individual characters in string.Is it not possible? And is there a way to change the string to 'char*'? Not const char* because I need to use it on the program.
Thanks in advance.

This question has already been answered. Start a new discussion instead.