Manuel García
/* Este programa lee un texto introducido por teclado y lo reescribe en mayúsculas */
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 1000
using namespace std;
int main()
{
char texto[MAX], x[MAX];
int i;
cout << “Introduce un texto:” << endl;
gets(texto);
cout << endl << “El texto en letras mayusculas es:” << endl;
for (i=0;i<strlen(texto);i++)
{
if (texto[i]>=’a’ && texto[i]<=’z’)
{x[i]=’A’+(texto[i]-‘a’);
cout << x[i];}
else
cout << texto[i];
}
cout << endl << endl;
system(“pause”);
return 0;
}
Anuncios
está ok pero el vector x[i] es superflúo.