Hey everyone i coded you a xmas card :D run it! run it! woop

HAPPY CHRISTMAS GUYS :D

But first you have to save all this as a text file sry i had to go to bed before i put the finishing touches on (at GFs mums)here tis:

---AA----AA--AA--AAAAAA--AA--AA--AA--AA--AA--AA-

-BBBB----B---BB--BBBBBB--B---BB--B---BB--BBBBBB-

---CC----CC--CC--CC------CC------CC--CC----CC---

-DDDD----D---DD--D---DD--D---DD--D---DD--DDDD---

-EEEEEE--EE------EEEEEE--EE------EE------EEEEEE-

-FFFFFF--FF------FFFF----FF------FF------FF-----

---GG----GG--GG--GG------GG-GGG--GG--GG----GG---

-HH--HH--HH--HH--HHHHHH--HH--HH--HH--HH--HH--HH-

--IIII-----II------II------II------II-----IIII--

--JJJJ-----JJ------JJ------JJ------JJ-----JJ----

-KK--KK--KKKK----KK------KKK-----KK-KK---KK--KK-

-LL------LL------LL------LL------LL------LLLLLL-

-MM--MM--M-MM-M--M----M--M----M--M----M--MM--MM-

-NN--NN--N-N--N--N--N-N--N---NN--N----N--NN--NN-

---OO----OO--OO--OO--OO--OO--OO--OO--OO----OO---

--PPPP----PP--P--PPP--P--PPPPP----PP------PP----

---QQ----QQ--QQ--QQ--QQ--QQ--QQ--QQQQ--------Q--

-RRRR----RR--RR--RRRR----RR--RR--RR--RR--RR--RR-

---SS----SS--SS---SS--------SS---SS--SS----SS---

-TTTTTT----TT------TT------TT------TT------TT---

--U--U---UU--UU--UU--UU--UU--UU--UU--UU----UU---

-V----V--V----V--VV--VV--VV--VV---VVVV-----VV---

--WW--WW--W----W--W----W--W-WW-W--W-WW-W---W--W--

-XX--XX---X--X-----XX-----X--X----X--X---XX--XX-

-YY--YY--YY--YY---YYYY-----YY------YY------YY---

-ZZZZZZ-----ZZ-----ZZ-----ZZ-----ZZ------ZZZZZZ-
------------------------------------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include <fstream>
#include <vector>
#include <sstream>
#include <string>

class alphabet
{
public:
     alphabet(char omega)
    {
        std::ifstream letterfile ("letters.txt");
        for (int q = 0; q<27; q++)
            for (int z = 0; z<48; z++)
                letterfile >> box[q][z];
        char zeta[27]= {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' '};
        for(int a = 0; a<27; a++)
            alpha[a]=zeta[a];
        int num;
        for (int a = 0; a<27; a++)
        {
            if (alpha[a]==omega)
                num=a;
        }
        int boxcounter=0;
        for (int b = 0; b<6; ++b)
            for(int c = 0; c<8; ++c)
            {
                if(box[num][boxcounter]=='-')
                    box[num][boxcounter]=' ';
                arr[b][c]=box[num][boxcounter];
                boxcounter++;
            }
    }
    char arr [6][8];
    char box [27][48];
    char alpha [27] ;
};


std::string blit (std::string words)
{
    std::vector <alphabet> letters;
    std::string sentence=words.c_str();
    for (int b = 0; b<sentence.length(); b++)
        letters.push_back(alphabet(sentence[b]));

    for (int nextline=0; nextline<6; nextline++)
    {
        std::cout<<std::endl;
        for (int nextletter=0; nextletter<sentence.length(); nextletter++)
            for(int nextpixel=0; nextpixel<8; nextpixel++)
                std::cout<<letters[nextletter].arr[nextline][nextpixel];
    }
}
int main ()
{
blit("merry xmas");
blit("  luv dr");
}


so now i have gone through the trouble of coding all of you a xmas card i think you should all work on my birthday present, you only have till august so i suggest you pool together work in shifts and employ some extra people :P
*xmas bump*
closed account (18hRX9L8)
Nice, but it crashes after 1 second. =D
1
2
3
4
5
6
7
8
9
10
11
12
13
bool First = true;
for(char c = 'A';c <= 'Z';c++)
{
	if(First == true)
printf("---%c%c----%c%c--%c%c--%c%c%c%c%c%c--%c%c--%c%c--%c%c--%c%c--%c%c--%c%c-",
           c,c,     c,c,  c,c,  c,c,c,c,c,c,  c,c,  c,c,  c,c,  c,c,   c,c,  c,c);
	else
printf("-%c%c%c%c----%c---%c%c--%c%c%c%c%c%c--%c---%c%c--%c---%c%c--%c%c%c%c%c%c-",
         c,c,c,c,   c,   c,c,   c,c,c,c,c,c,   c,  c,c,   c,  c,c,   c,c,c,c,c,c);

	std::cout << endl;
First = !First; //Second -> First...
} 
Last edited on
@devonrevenge
For each instance of Alphabet you push into the vector you are opening and reading the file into memory (Alphabet::box).
Also, you can replace all this
1
2
3
4
5
6
7
8
9
char zeta[27]= {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' '};
        for(int a = 0; a<27; a++)
            alpha[a]=zeta[a];
        int num;
        for (int a = 0; a<27; a++)
        {
            if (alpha[a]==omega)
                num=a;
        }
with int num = (omega > 32) ? omega - 'a': 26;
closed account (18hRX9L8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <fstream>
#include <vector>
#include <sstream>
#include <string>

class alphabet
{
public:
     alphabet(char omega)
    {
        std::ifstream letterfile ("letters.txt");
        for (int q = 0; q<27; q++)
            for (int z = 0; z<48; z++)
                letterfile >> box[q][z];
        int num = (omega > 32) ? omega - 'a': 26;
        int boxcounter=0;
        for (int b = 0; b<6; ++b)
            for(int c = 0; c<8; ++c)
            {
                if(box[num][boxcounter]=='-')
                    box[num][boxcounter]=' ';
                arr[b][c]=box[num][boxcounter];
                boxcounter++;
            }
    }
    char arr [6][8];
    char box [27][48];
    char alpha [27] ;
};


std::string blit (std::string words)
{
    std::vector <alphabet> letters;
    std::string sentence=words.c_str();
    for (int b = 0; b<sentence.length(); b++)
        letters.push_back(alphabet(sentence[b]));

    for (int nextline=0; nextline<6; nextline++)
    {
        std::cout<<std::endl;
        for (int nextletter=0; nextletter<sentence.length(); nextletter++)
            for(int nextpixel=0; nextpixel<8; nextpixel++)
                std::cout<<letters[nextletter].arr[nextline][nextpixel];
    }
}
main ()
{
blit("happy new");
//std::cout<<"hi!"<<std::endl;
blit("year");
}


Okay, so I fixed up your code by using the suggestions above. Now then, when I try printing "happy new year" in Devon-Font, the program stops working when it tries to return back to main. It prints "happy new", but when it tries to go down to the next line, it crashes. It doesn't even print the tester on line 52, which I commented. You need to add some newline character which allows the program to print sentences. I would do this, but I don't know how to since I'm a noob. (I openly admit now.)
@usandfriends
Runs fine for me when run through VS2010 and when run directly in the terminal.
closed account (18hRX9L8)
Okay, I just downloaded the new Orwell Dev C++ and uninstalled my Bloodshed Dev C++ and it still crashes.
You liked it? it was for you guys.
there was so many faults with it just i couldnt get it running as i wanted it to in time for xmas :/

could someone use this to judge where im at though? this is the result of 2 and a half months learning, is it going slow? am i doning okay? so far i have given myself a yellowbelt in c++

EDIT: please use devon-font for stuff.
Last edited on
closed account (18hRX9L8)
It still crashes after blit("happy new") on my program (see above).
EDIT: Even with my fancy new Orwell Dev C++ IDE.
Last edited on
yeah it still crashes for me too, but it still prints out the stuff it needed to first :D

its got something to do with looping too many times somewhere
closed account (18hRX9L8)
yeah it prints out "happy new" in Devon-Font but then it crashes. It crashes right before the blit() program ends. It loops just the way it should.
Last edited on
Topic archived. No new replies allowed.