-
Tips for project
I have to do this project in my C++ class but I am not certain how, any tips or hints would be appreciated.
The problem reads as follows...
"declare a character array named Alpha and initialize it to ABCDE...
In your program, include a loop that replaces one character at a time with the lowercase letters a-z. Print the character array to the screen during each iteration of the loop.
-
To initilize an array to ABCDE, do this:
char Alpha[] = {"ABCDE"};
then just loop though the array and assign all the elements with their equvilant lowercase values. I don't want to tell you too much, because that would diminish the point of the exercise, but try:
(int)Alpha[i] -= ('A' - 'a');
Good luck.
-
The easiest way to change the captialisation on a letter would be:
Alpha[i] ^= 0x20;
It works most of the time, but it doesn't go too well when a something other than a letter is encountered.
-
Well the entire program is given below.. This is how you do it. Run this program and you will get the result you want.. This program was done using turbo c++
# include <iostream.h>
# include <conio.h>
main()
{
clrscr();
int i;
char alpha[26]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for(i=0;i<26;i++)
{
alpha[i]=alpha[i]+32;
cout<<alpha[i];
}
}
-
stupid question but ill ask it
i saw several times the clrscr() around
but when i try to compile something in microsoft c++ enterprise edition it gives me an error always undeclared idientifier??
-
clrscr() is only good for Windows based systems since it is a thin encapsulation of a Windows function. But anyway, #include <conio.c>