Jump to content
mtrriba

converter strings de minusculas para maiusculas

Recommended Posts

mtrriba

Como posso eu converter uma string de minúsculas para maiúsculas

estou a utilizar da seguinte forma mas da-me erro.

m1[nlinhas]=toupper[nlinhas];

Share this post


Link to post
Share on other sites
KTachyon
int i;
for (i = 0; i < tamanho; i++) {
    str[i] = toupper(str[i]);
}


“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

-- Tony Hoare

Share this post


Link to post
Share on other sites
bubulindo

Ou

int i;
for (i = 0; i < tamanho; i++) {
    str[i] -=32;
}

Mas a solucão anterior é mais segura. :thumbsup:

Se quiseres perceber o porquê do 32, vê aqui: http://www.asciitable.com/


include <ai se te avio>

Mãe () {

}

Share this post


Link to post
Share on other sites
KTachyon

Pois, é mais segura porque, na tua solução, caso já seja maiúscula... chapéu :thumbsup:

Mas, por outro lado, só funciona para ASCII. Portanto, esquece acentos e cedilhas.


“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

-- Tony Hoare

Share this post


Link to post
Share on other sites
bubulindo

Não discordo, se for um número ou sinal faz algo semelhante e transforma-o em algo... não pretendido.

Mas não deixa de ser interessante mostrar a forma básica de o fazer e porque é que é assim. :thumbsup:


include <ai se te avio>

Mãe () {

}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.