l33t program not working

Hi, how do you convert a sentence such as:
"I can has Cheezeburger!", to leet.
you have to change the sentence to uppercase first (not sure how thats done) then convert to leet
this my attempt but its not working

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

//leet
#include <iostream>
#include <cctype>
using namespace std;
int main()
{
        //declarations
	int y = 0;
	const int size = 50;
	char converter[size];
	char leet[size];

	//entering sentence
	cout << "Enter a phrase to change to 1337: \n";
	cin.getline(converter, size);

        //have to change to uppercase

	cout << "The 1337 phrase is: \n";

        //trying to convert the sentence
	for(int count = 0; count < size; count++) 
		{
			if(converter[count] == 'I')
				leet[count] = '1';
			if(converter[count] == 'Z')
				leet[count] = '2';
			if(converter[count] == 'E')
				leet[count] = '3';
			if(converter[count] == 'A')
				leet[count] = '4';
			if(converter[count] == 'S')
				leet[count] = '5';
			if(converter[count] == 'O')
				leet[count] = '0';			
		}

        //trying to output the leet sentence
	while( leet[y] != '\0')
		{
			cout << leet[y];
			y++;
		}
	return 0;
}


any sort of help will be welcome.
ps: the last time i compiled it it was working, not sure if it still works
1
2
3
#include <cctype>
for(int i = 0; i < size; ++i) 
     converter[i] = toupper(converter[i]);

It's as simple as that.
thanx for your help...any idea on what i'm doing wrong with the code on converting the sentence to leet.
How about you start by explaining what the alleged problem is...
Change if statement to this...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
if(converter[count] == 'I')
  leet[count] = '1';
else if(converter[count] == 'Z')
  leet[count] = '2';
else if(converter[count] == 'E')
  leet[count] = '3';
else if(converter[count] == 'A')
  leet[count] = '4';
else if(converter[count] == 'S')
  leet[count] = '5';
else if(converter[count] == 'O')
  leet[count] = '0';	
else
  leet[count] = converter[count];


When outputting your string, just do it like this...
 
cout << leet;


You'll need to add the uppercase conversion in before the existing for loop. That should do it.
Topic archived. No new replies allowed.