Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: [Example / Listing] I made my first decent C++ application! (AACM v1.1)  (Read 1841 times)

0 Members and 1 Guest are viewing this topic.
[Example / Listing] I made my first decent C++ a...
« on: May 12, 2006, 09:36:52 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 221
I made my first decent C++ application -- at least I think it's decent. It is a console application, but it accomplishes what it tries to do.

Anyway, I'm sure some of you have encountered one of those annoying webpages that make like 100 alert messages pop up before they finally let you free. Well, with my program, "The Annoying Alert-Chain Maker", you can now make your own! Although I'm sure most of the people on this board are perfectly capable of making one themself, there are some (small) benefits to using the AACM. For one, it can make the files faster than you can. (BTW that wasn't meant as an insult o_0) Also, if you don't know the Javascript function for making an alert pop-up thingy, you don't need to, because the AACM does it for you! Yay! Go AACM! <_<; So, anyway, here's the code!

Code: [Select]
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{
    string tempStr, name;
    char fname[80];
    int n;
    cout << "Annoying Alert-Chain Maker v1.1\n";
    cout << "       by Joe Buck\n\n\n";
    cout << "What is your name or alias?\n";
    getline(cin, name);
    cout << "\n\nWhat should I name the file? (Use \"\\\\\" for \"\\\". Be sure to include \".html\")\n";
    cin.getline(fname, 80);
    ofstream outfile;
    outfile.open(fname);
    cout << "\n\n";
    cout << ">>Created the file \"" << fname << "\"\n";
    outfile << "<html>\n<title>" << name << "'s Annoying Alert-Chain</title>\n<body>\n<script type=\"text/javascript\">\n\n";
    cout << "Use \\n for linebreaks and \\\" for double quotes.\n";
    cout << "Type \"Exit\" when you are finished.\n\n";
    for (n=0;true;n++)
    {
        cout << "Type what you want for Alert " << n+1 << ".\n";
        getline(cin, tempStr);
        if (tempStr=="Exit" || tempStr=="exit")
            break;
        outfile << "    alert(\"" << tempStr << "\");\n";
    }
    outfile << "\n</script>\n<font size=-1>\nThis file was made in Joe Buck's Annoying Alert-Chain Maker. \n<a href=\"http://cheesypoof.unitedstates.com\">Official Site</a>\n</font>\n</body>\n</html>";
    outfile.close();
    cout << "\n";
    cout << "File saved!\n";
    cout << "Have a nice day! :)\n\n";
    system("PAUSE");
    return 0;
}


Also, for another little project I thought of (that would be much more use than this, lol) I need to know some things about file output and/or binary file output. How do you insert something in the beginning or middle of a file? Also, how would you delete part of a file so that the things that were before and after it would be right next to each other? If anyone could answer some of these questions or recommend a tutorial that answers them I'd greatly appreciate it.

EDIT: Now you can pick the filename! (That's what the fname variable that I forgot to delete was :) ) C+C please!
« Last Edit: February 24, 2012, 06:34:55 pm by Niek »
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.015 seconds with 39 queries.

anything