Hello I am trying to write a program that removes spaces before and after and reduce to one between words and capitalize the first letter of each world and the other letters lowercase but I'm getting errors which I can't make heads and tail of.
|12|error: expected primary-expression before ')' token|
22|error: invalid conversion from `char' to `char*'|
|27|error: invalid conversion from `int' to `char*'|
|35|error: invalid operands of types `char*' and `char*' to binary `operator+'|
# include <iostream>
# include <cstdio>
# include <cstring>
using namespace std;
void formatering ( char *str, char *tempstr, char *string);
int main()
{
char tempstr[80];
char str[80];
cin >> str;
gets (str);
formatering (str, tempstr, string);
return 0;
}
void formatering ( char *str, char *tempstr, char *string) //unsigned
{
int a = 0;
int b = 0;
while (*str != '\0')
{
if ( *str == ' ' && a == 1 && b == 1)
{ tempstr = *str;
b = 0;
}
else if (a == 0 && (*str >= 'A' && *str <='Z') || (*str >= 'a' && *str <='z'))
{
tempstr = toupper(*str);
a = 1;
b = 1;}
else if (a == 1 && (*str >= 'A' && *str <='Z') || (*str >= 'a' && *str <='z'))
{
*str = tolower(*str + 1);
}
str++;
string = (string + tempstr);
}
tempstr--;
if (*str = ' ') {
*tempstr--;}
*tempstr++;
*tempstr = '\0';
cout << string;
}