#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define QTD_NOMES 2
#define TAM_NOME 30
int soChars(char *nome, int tamanho) {
for (int i = 0; i < tamanho; i++) {
printf("\nNome invalido!\nDigite apenas letras!\n"); return 0;
}
}
return 1;
}
void leValidaNome(char *nome) {
while (1) {
if (tamanho
== 0) printf("\nNome invalido!\nDigite algo!\n"); else if (soChars(nome, tamanho)) return;
}
}
int main() {
char nomes[QTD_NOMES][TAM_NOME];
for (int i = 0; i < QTD_NOMES; i++) leValidaNome(nomes[i]);
for (int j
= 0; j
< strlen(nomes
[0]); j
++) nomes
[0][j
] = toupper(nomes
[0][j
]); for (int i = 1; i < QTD_NOMES; i++) {
for (int j
= 0; j
< strlen(nomes
[i
]); j
++) nomes
[i
][j
] = tolower(nomes
[i
][j
]); }
printf("\n%s\n%s", nomes
[0], nomes
[1]); }
//https://pt.stackoverflow.com/q/326024/101
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN0cmluZy5oPgojaW5jbHVkZSA8Y3R5cGUuaD4KI2RlZmluZSBRVERfTk9NRVMgMgojZGVmaW5lIFRBTV9OT01FIDMwCgppbnQgc29DaGFycyhjaGFyICpub21lLCBpbnQgdGFtYW5obykgewogICAgZm9yIChpbnQgaSA9IDA7IGkgPCB0YW1hbmhvOyBpKyspIHsKICAgICAgICBpZiAoaXNkaWdpdChub21lW2ldKSAhPSAwKSB7CiAgICAgICAgICAgIHByaW50ZigiXG5Ob21lIGludmFsaWRvIVxuRGlnaXRlIGFwZW5hcyBsZXRyYXMhXG4iKTsKICAgICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIDE7Cn0KCnZvaWQgbGVWYWxpZGFOb21lKGNoYXIgKm5vbWUpIHsKICAgIHdoaWxlICgxKSB7CiAgICAgICAgcHJpbnRmKCJJbmZvcm1lIHNldSBub21lOiIpOwogICAgICAgIHNjYW5mKCIgJVteXG5dcyIsIG5vbWUpOwogICAgICAgIGludCB0YW1hbmhvID0gc3RybGVuKG5vbWUpOwogICAgICAgIGlmICh0YW1hbmhvID09IDApIHByaW50ZigiXG5Ob21lIGludmFsaWRvIVxuRGlnaXRlIGFsZ28hXG4iKTsKICAgICAgICBlbHNlIGlmIChzb0NoYXJzKG5vbWUsIHRhbWFuaG8pKSByZXR1cm47CiAgICB9Cn0KCmludCBtYWluKCkgewogICAgY2hhciBub21lc1tRVERfTk9NRVNdW1RBTV9OT01FXTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgUVREX05PTUVTOyBpKyspIGxlVmFsaWRhTm9tZShub21lc1tpXSk7CiAgICBmb3IgKGludCBqID0gMDsgaiA8IHN0cmxlbihub21lc1swXSk7IGorKykgbm9tZXNbMF1bal0gPSB0b3VwcGVyKG5vbWVzWzBdW2pdKTsKICAgIGZvciAoaW50IGkgPSAxOyBpIDwgUVREX05PTUVTOyBpKyspIHsKICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IHN0cmxlbihub21lc1tpXSk7IGorKykgbm9tZXNbaV1bal0gPSB0b2xvd2VyKG5vbWVzW2ldW2pdKTsKICAgIH0KICAgIHByaW50ZigiXG4lc1xuJXMiLCBub21lc1swXSwgbm9tZXNbMV0pOwp9CgovL2h0dHBzOi8vcHQuc3RhY2tvdmVyZmxvdy5jb20vcS8zMjYwMjQvMTAx