so i made this halloween ascii displaying program for a school project, and i was wondering how i would get the ascii to display as it is written in the program. Whenever i start and display the ascii the image is distorted. Also, how would i modify the if and else statements so that typing in a string in either upper or lower case would trigger a response from the program. For example, i want to be able to type in "pretty flower in any form (all caps, only the t's capitalized, only the f l e r capitalized, all lowercase, etc) and what the image to display for each of these. Here's the program.
//Halloween Selection.cpp - displays a halloween image or halloween celebratory remark depending on what the user inputs
#include <iostream>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::string;
int main()
{
//declare variables
string (name) = "";
the ascii is normal in the program i built, the comment formatting throws it off here. I also had to find a code to change the text color for each of these images in command prompt, would i have to input this code into the actual program?
If u want to change the text color...i would suggest u to add something like.... system("color 1")
which....
0 = Black 8 = Gray
1 = Blue 9 = Light Blue
2 = Green A = Light Green
3 = Aqua B = Light Aqua
4 = Red C = Light Red
5 = Purple D = Light Purple
6 = Yellow E = Light Yellow
7 = White F = Bright White
So, is their a function to use so that the if/else statement works whether the string "pretty flower" is all capitalized or all lowercase, or if some of the letters are capitalized while others are lower case?
and how would i normalize the input if that solves the problem
Do you know user made functions or is that not covered yet?
Anyway STL C++ does not define a function for this but its not that hard to write.
My solution:
1 2 3 4 5 6 7 8 9
bool isSimilarString(std::string str, std::string comp)
{
for (std::string::iterator it = str.begin(); it != str.end(); ++it)
*it = tolower(*it);
for (std::string::iterator it = comp.begin(); it != comp.end(); ++it)
*it = tolower(*it);
return ((str == comp) ? true : false);
}
This converts both the string and he string you wish to compare and checks to see if their spelling matches. It forces both strings to lower case and then does a regular string compare.