hello everyone i am new to this community . i am having a problem right now with arrays. So basically this program let user to enter anything in lowercase and then convert it to uppercase(if user input uppercase it will stay the same). Because i am not allowed to use toupper(), i subtract 32 from lower case ASCII code so that i get upper case.

my problem is the console output,as you can see '╠' these are weird characters. can anyone tell me how to omit those in the console output?

Please Enter a string of 80 or fewer characters
HELLO EVERYONE ╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
╠Press any key to continue . . .

#include <iostream>
#include <iomanip>
using namespace std;
int main()
	const int NUM_LETTERS = 81;     //80 characters and 1 space for null terminator
	char line[NUM_LETTERS];
	char newline;
	cout<< endl << "Please Enter a string of 80 or fewer characters" << endl;
	cin.getline(line,NUM_LETTERS);             //get string from user

	for (int count = 0 ;count < NUM_LETTERS; count ++)       //loop
		if(line[count]>= 97 && line[count]<=122) // check if characters are lowercase.
		  line[count] = line[count] - 32; // convert to uppercase.
		else if (line[count] >=65 && line[count] <=90); //check if there are uppercase in userinput.
			line[count] = line [count];   //upper case stay the same.
		cout << line[count];
7 Years
Discussion Span
Last Post by hzp

cout << line[count] // <--- you are returning uninitialized data, as the variable count can be greater than the size of your input.


i just solved it already. thank you anyway

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.