University Homework Help

My assignment is to:

Write a complete C++ program that read in from the key board a string and convert all letters in the string to upper cases. You are not allowed to use toupper function.

Note I am new to c++ I do not know how to do this if any one can help me please do so thank you
1
2
3
4
read a string in S

Then for every character C in S,
convert C to Uppercase
You are not allowed to use toupper function. then you should go to ascii values of every character and manually convert every character
Hilarious that teachers want to give these USELESS assignments. If a function is available for you to convert to upper case (i.e. the toupper() ) function, why would you EVER want to manually write one? Just a waste of time...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Function Prototype
string ToUpperCase(string text); 

//Useless manual Function your teacher is making you write
// to convert to Upper Case
string ToUpperCase(string text)
{
  for(int i = 0; i<text.length(); i++)
  {
     char c = text[i]; 
     if((c>=97)&&(c<=122))
    {
	 text[i]&=0xdf; 
    }
  }
  return text;
}
Last edited on
@Shamieh that was just given that students to know how toupper(); functions work
Topic archived. No new replies allowed.