Help With String Parsing

I really have no idea why it's not working, but I'm trying to convert a double into a string to count the number of characters. It works, but if I have an umber greater than 999999(has 7 or more numbers) it changes it to an exponent. It doing so messes up the number of characters. I heard string parsing would work, but I don't know how...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
void getVarLengths(double number1, double number2, double number3, int &count1, int &count2, int &count3)
{
	cout << number1 << endl;
	cout << number2 << endl;
	cout << number3 << endl;

	//For large numbers
	//First so that it doesn't put them in scientific form
	if (number3 > 999999)
		cout << fixed << setprecision(7); 
	if (number3 > 9999999)
		cout << fixed << setprecision(8);
	if (number3 > 99999999)
		cout << fixed << setprecision(9);
	if (number3 > 999999999)
		cout << fixed << setprecision(10);

	//Declare variables
	ostringstream sstream1; //I think this is another way to declare a variable
	sstream1 << number1; //Put the number into the ostringstream variable
	string first = sstream1.str(); //And then that into a regular string
	ostringstream sstream2; //Same
	sstream2 << number2; //Put the number into the ostringstream variable
	string second = sstream2.str(); //And then that into a regular string
	ostringstream sstream3; //Same
	sstream3 << number3; //Put the number into the ostringstream variable
	string third = sstream3.str(); //And then that into a regular string

	cout << first << endl;
	cout << second << endl;
	cout << third << endl;

	count1 = first.length();
	if (number2 != 0)
		count2 = second.length();
	//End if
	count3 = third.length();

	cout << count1 << endl;
	cout << count2 << endl;
	cout << count3 << endl;

	cout << fixed << setprecision(0);
}


Some of it really is just for debugging.

Thanks!
Topic archived. No new replies allowed.