need some info..

This is a discussion on need some info.. within the C Programming forums, part of the General Programming Boards category; i want to creat a program that can print my name in "*" (stars) but i have no idea on ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    227

    need some info..

    i want to creat a program that can print my name in "*" (stars) but i have no idea on how to start it.. or what do to.. im still a newbie.. all i have created ever as a cal..(for thouse who know) and how i want to creat a program that can print out my name in * . also if i do i want to understand itz functions.. would anyone mind telling me how to start this.. or how to learn how to do this.. thanx (great knowledge for a stupid kid.)

  2. #2
    Unregistered
    Guest
    ok this code will probly be pretty hard to understand but I will try, first you need to understand boolean algebra:

    #include <stdio.h>

    long charset[24];

    /*
    *** **** *** **** ***** ***** *** * * *** * * * *
    * * * * * * * * * * * * * * * * * * *
    ***** **** * * * *** *** * ***** * * ** *
    * * * * * * * * * * * ** * * * * * * * *
    * * **** *** **** ***** * *** * * *** *** * * *****

    * *
    ** **
    * * *
    * *
    * *

    A = 1000110001111111000101110 = 18415150
    B = 0111110001011111000101111 = 16301615
    C = 0111010001000011000101110 = 15238702
    D = 0111110001100011000101111 = 16303663
    E = 1111100001001110000111111 = 32545855
    F = 0000100001001110000111111 = 1088575
    G = 0111011001000011000101110 = 15500846
    H = 1000110001111111000110001 = 18415153
    I = 0111000100001000010001110 = 14815374
    J = 0111010001100001000010000 = 15254032
    K = 0100100101000110010101001 = 9604265
    L = 1111100001000010000100001 = 32539681
    M = 1000110001101011101110001 = 18405233

    */

    void assignchars()
    {
    charset[0] = 18415150; //A
    charset[1] = 16301615; //B
    charset[2] = 15238702; //C
    charset[3] = 16303663; //D
    charset[4] = 32545855; //E
    charset[5] = 1088575; //F
    charset[6] = 15500846; //G
    charset[7] = 18415153; //H
    charset[8] = 14815374; //I
    charset[9] = 15254032; //J
    charset[10] = 9604265; //K
    charset[11] = 32539681; //L
    charset[12] = 18405233; //M
    }

    void printchars(char name[])
    {
    long counter;
    int namecounter;
    int tempcharpos;
    int bitpos;
    int origposx;
    int origposy=wherey();

    for(namecounter=0;namecounter<strlen(name);namecou nter++)
    {
    origposx=wherex();

    tempcharpos=toupper(name[namecounter])-65;
    bitpos=1;
    for(counter=1;counter<=33554431;counter*=2)
    {
    if((charset[tempcharpos] & counter)>0)
    {
    gotoxy(origposx+(((bitpos-1)%5)+1),origposy+(((bitpos-1)/5)+1));
    printf("*");
    }
    bitpos++;
    }
    gotoxy(origposx+6,origposy);
    }
    }

    void main()
    {
    assignchars();

    printchars("ABCDEFG");
    printf("\n\n\n\n\n\n");
    printchars("HIJKLM");
    printf("\n\n\n\n\n\n");
    }

    ok each letter is defined as a number, using long variables you have 32 distinct bits in it, to test for each one you can get the number and do
    num & value
    where num is the number definition and value is say 4 to test the 3rd bit from the right.
    to create a new letter, type in the letter as you want it to look like, like I have done at the top and type a * as 1 and a space as 0, and start from the bottom right and go backwards so
    A = 1000110001111111000101110
    A to M are already done.

    Ok now to explain the code, the function printchars checks how many letters it gets passed, it then analyses 1 letter at a time
    it minus's 65 off the letter so that A will equal 0, B equals 1, etc
    it then looks at the definition for the specific letter defined in charset and tests each bit in the integer starting from bit 1 and stops at bit 25 which is defined by 2nd for statement (33554431 is the maximum value that a character could have using a 5x5 structure. if a value is read then it will print a * in the correct position.

    Hope this helps if ya need any more help or explanation just let me know and I will comment the code.
    Enjoy
    Regards, Bull

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    227
    errr well first off all thanx for yoru reply second im to stupid and the code is to advanced for me hehe.... is there another way on how to creat it more lipler.....thanx

  4. #4
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    you could probably hardcode it like this

    Code:
    cout<<"****";
    cout<<"*    *";
    cout<<"*    *";
    cout<<"****";
    cout<<"*    *";
    cout<<"*    *";
    cout<<"*    *";

  5. #5
    Registered User
    Join Date
    Mar 2002
    Posts
    9

    Talking

    i think "ihsir" is missing "endl;"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help displaying info from structure
    By kisiellll in forum C Programming
    Replies: 6
    Last Post: 04-04-2009, 01:51 PM
  2. Question about getting an info class from another Form
    By Joelito in forum C# Programming
    Replies: 0
    Last Post: 10-16-2006, 02:02 PM
  3. Help doing an e-mail program in c...
    By Tyler_Durden in forum C Programming
    Replies: 88
    Last Post: 01-02-2005, 03:12 PM
  4. Binary trees search problem...
    By Umoniel in forum C Programming
    Replies: 2
    Last Post: 02-22-2004, 02:29 PM
  5. Replies: 3
    Last Post: 12-06-2001, 05:30 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21