Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Insert problem

$
0
0
Hi
Im having trouble with this line of code what I am trying to do is add the counter to # so it works like this

#1, #2, #3 but for some reason the int isn't added to the end?

num.insert( counter, "#" + counter );



void CubeData::findXYZPoints1()
{

	string num = " -2.996580 -1.823648 2.654824";

	unsigned int counter = 0;
	
        cout << "Size of String: " << num.length() << endl;

	while( counter < num.length() )
	{
		if( ' ' == num.at( counter ) )
		{
			num.erase( counter, 1 );
			num.insert( counter, "#" + counter );
			counter++;			
		}
		counter++;
	}
	cout << "Size After insert: " << num.length() << endl;
	cout << "Replace:" << num << endl;
}



Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>