Hey guys,
I've seen a lot of posts around the internet about this, but I still don't understand how to do that exactly. For some reason, I can only uppercase my char array until there is a space...
#include "stdafx.h"
#include <iostream>
#include <string>
std::string caps (char[]);
int main() {
const int MAXLEN = 256;
char chaine[ MAXLEN ] = "";
//Here i am inputting my list of char into my array
std::cout << "Chaîne ? ";
std::cin >> chaine;
//Calling my caps function
caps( chaine );
// results
std::cout << "Résultat: " << chaine << std::endl;
_gettch();
return 0;
}
std::string caps (char chaine []){
std::string check=chaine;
for (int i=0; i<=check.length(); i++){ //I added check.length() because it's the only way I know to check for the length of the array
chaine[i]=toupper(chaine[i]);
}
return chaine;
}
So let's say I write "Hey you" The output will be "HEY" and that's it. I am le confused. Thanks for the help!