Conversion errors all the time

I just started in C++ and I've been getting tons of data type conversion errors when I try to compile, especially when using library functions. Is there any good tips to avoid these errors and is there a good tutorial that explains the problem and how to properly use data types? I'm at the point where I could write a nice program, if I could just spend less time with these problems.
Last edited on
Conversion errors or warnings?

Can you give some examples?
For example:
1
2
3
4
5
6
7
8
9

string big = "UPPERCASE WORDS ARE HERE.";
	stringstream little(big);
	string temp;
	while (getline(little, temp, '.')){
		tolower(little) >> temp;
	}
	cout << "Temp little: " << temp << endl;


error:
 
error C2664: 'tolower' : cannot convert parameter 1 from 'std::stringstream' to 'int'


It's hindering my ability to have the confidence I need to pick up chicks in the bar. I'm like - "Hi - I can't convert parameter 1 from stringstreams to ints.., want to go back to my place?"

I'm not even sure why tolower would want to convert to ints anyways?
Last edited on
Use a loop and cycle each char of the string?
1
2
3
4
5
6
7
8
std::string big = "UPPERCASE WORDS ARE HERE.";

for( unsigned int idx = 0; idx < big.length(); ++idx )
{
	big[ idx ] = tolower( big[ idx ] );
}
	
std::cout << big << '\n';
I'm not sure if a large chunk of the syntax is getting lost in translation between writing Visual Basic in class by learning from a pseudo code book (not language specific), and trying to learn C++ at the same time at home....
Last edited on
When using a library function, the starting point is to look up the reference page for that function. http://www.cplusplus.com/reference/cctype/tolower/

int tolower ( int c );

As you can see, the function takes an int parameter and returns an int result. Put simply, it converts a single character to lowercase.

No wonder the compiler wasn't happy, it expected just one character, but instead found a whole big stringstream there.


Last edited on
Topic archived. No new replies allowed.