Thread: need help with output

  1. #1
    Registered User
    Join Date
    Oct 2013
    Posts
    3

    need help with output

    Hello. I am trying to get this program to read a user string and output the message in large block letters. I have it set to where it prints out the letters the user types in, but they output vertically. I am trying to get them to output horizontally like an actual word. Could somebody please help me?

    (note: I only did letter a-f for now but once I get it working I will add the rest.)

    Thanks


    Code:
    #include <iostream>
    #include <string>
    #include <cmath>
    #include <cstdlib>
    #include <stdio.h>
    #include <Windows.h>
    
    using namespace std;
    
    
    struct letter {
    
      string lines[5];
    
    } A = {
    
    " AAA ", 
    "A   A", 
    "AAAAA", 
    "A   A", 
    "A   A"};
    
    letter B = {
    
      "BBBB ",
      "B   B",
      "BBBB",
      "B   B",
      "BBBB "
    };
    
    letter C = {
    
      " CCCC",
      "C    ",
      "C    ",
      "C    ",
      " CCCC"
    };
    
    letter D = {
    
      "DDDD ",
      "D   D",
      "D   D",
      "D   D",
      "DDDD "
    };
    
    letter E = {
    
      "EEEEE",
      "E    ",
      "EEEEE",
      "E    ",
      "EEEEE"
    };
    
    letter F = {
    
      "FFFFF",
      "F    ",
      "FFFF ",
      "F    ",
      "F    "
    };
    
    
    int main()
    {
    
      string first;
      char firstChar;
      int a, b;
      letter array[6] = { A, B, C, D, E, F };
      cout << "Please enter a message: ";
      cin >> first;
    
    
    
      for (int j = 0; j < first.size(); j++) {
        firstChar = toupper(first[j]);
        firstChar -= 'A';
    
        for (int i = 0; i < 5; i++) {
          cout << array[firstChar].lines[i] << endl;
    
    
    
        }
    
    
      }
    
      return 0;
    
    }
    Last edited by Salem; 10-30-2013 at 12:21 AM. Reason: stop using colour in your code, it adds NOTHING and only serves to screw up formatting

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    You'd have to print the first line of each letter in the message, separated by a couple of spaces. Then print the second line of each letter in the message. Then....
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ overlapping output and adding extensions to output files
    By lordmorgul in forum Linux Programming
    Replies: 9
    Last Post: 05-11-2010, 08:26 AM
  2. How to edit output in struct and call for the output
    By andrewkho in forum C Programming
    Replies: 4
    Last Post: 03-16-2010, 10:28 PM
  3. terminal output not showing output properly
    By stanlvw in forum C Programming
    Replies: 13
    Last Post: 11-19-2007, 10:46 PM
  4. output a string to a standard output
    By sh4k3 in forum C Programming
    Replies: 3
    Last Post: 06-15-2007, 05:59 AM
  5. Replies: 3
    Last Post: 02-19-2003, 08:34 PM