Kod: Zaznacz cały
// uppercase_letter.cpp : main project file.
#include "stdafx.h"
#include <iostream>
#include <cctype>
using namespace std;
int i;
void enter ( char str[] );
void toUppercase ( char str[] );
void print (char str[] );
int main()
{
char text[999];
cout<<"Program converts letters in your text to uppercase \n ";
enter ( text );
cout<<endl;
toUppercase ( text );
cout<<endl;
print ( text );
cout<<endl;
cout<<endl;
system("PAUSE");
}
void enter ( char str[] )
{
for ( i= 0 ; i < 999 ; i++)
{ cin >> str[i];
if (str[i]== '\n')
break;
}
}
void toUppercase ( char str[] )
{
for ( i = 0 ; i < 999 ; i++)
str[i] = static_cast<char>(toupper( str[i] ));
}
void print ( char str[] )
{
for (i = 0 ; i < 999 ; i++)
cout<< str[i] << endl;
}
po naciśnięciu klawisza enter program powinien wyświetlić wszystkie wpisane wcześniej litery jako WIELKIE.
Problem w tym , że tak nie jest , wygląda na to że warunek w if'ie jest zawsze prawdą . Jak rozgryźć tę instrukcję warunkową?