sciguy Posted January 23, 2010 Share Posted January 23, 2010 Ok, I started programming in c++, so I am on a mission to create interesting programs. Here is one that is basically a birthday card. Feel free to use it yourself! bdaycardprog.zip Link to comment Share on other sites More sharing options...
Addictgamer Posted January 23, 2010 Share Posted January 23, 2010 Cool. I guess I should also repost my old programs topic soon. Link to comment Share on other sites More sharing options...
sciguy Posted January 23, 2010 Author Share Posted January 23, 2010 It isnt much because im still learning. Hopefully I will soon come up with some better ones Link to comment Share on other sites More sharing options...
Sonic322 Posted January 23, 2010 Share Posted January 23, 2010 I can't use it It says that something is incorrect Link to comment Share on other sites More sharing options...
Addictgamer Posted January 23, 2010 Share Posted January 23, 2010 Try using a blank std::cin instead of SYSTEM("PAUSE"); Link to comment Share on other sites More sharing options...
sciguy Posted January 23, 2010 Author Share Posted January 23, 2010 ok, ill do that ( I told ya im still learning, any input is welcome oh, and I use "using namespace std;" so i dont need to add the "std::" in front of cin. Nope, doesnt work properly like that. Any other options to that and/or system("cls")? Link to comment Share on other sites More sharing options...
Addictgamer Posted January 24, 2010 Share Posted January 24, 2010 Hmm...Make a blank string object and have th ecin input to this, like #include <iostream> #include <string> using namespace std string buff; int main() { cin >> buff; return 0; } It will wait for the user to press enter. btw: http://www.lazyfoo.net/ Link to comment Share on other sites More sharing options...
sciguy Posted January 24, 2010 Author Share Posted January 24, 2010 only thing is, ya need to type something first, otherwise it resets the input stream and prompts you again Link to comment Share on other sites More sharing options...
Sonic322 Posted January 24, 2010 Share Posted January 24, 2010 "This application has failed to start because the application configuration is incorrect." That is it Link to comment Share on other sites More sharing options...
Acmex Posted January 24, 2010 Share Posted January 24, 2010 What are you using to program it? You might have to change some of the properties under "Configuration" if using MSVisual C++ Express edition. For what sonic said (Which, BTW, is probably not very helpful ) Link to comment Share on other sites More sharing options...
sciguy Posted January 24, 2010 Author Share Posted January 24, 2010 I fixed the problem. I was using system("pause"), which is an OS function and system dependant. here is the new source code: #include <iostream> #include <conio.h> #include <string> #include <fstream> #include <limits> using namespace std; string name; string lname; char ch; ifstream inData; int a; int main(){ cout<<"Press enter to continue..."<<endl; cin.ignore(numeric_limits<streamsize>::max(), '\n'); cout<<"Enter your name (first and last):"<<endl; cin>>name>>lname; system("cls"); cout<<"Happy birthday "<<name<<" "<<lname<<"!"<<endl<<endl; cout<<"Happy birthday to you,"<<endl<<"happy birthday to you,"<<endl; cout<<"Happy birthday "<<name<<" "<<lname<<","<<endl; cout<<"Happy birthday to you."<<endl; cout<<" s s s s s"<<endl; cout<<" __|__|__|__|__|__"<<endl; cout<<" | |"<<endl; cout<<" | |"<<endl; cout<<" {@@@@@@@@@@@@@@@@@}"<<endl; cout<<" | |"<<endl; cout<<" | |"<<endl; cout<<" @@@@@@@@@@@@@@@@@@@@@"<<endl; _getch(); system("cls"); inData.open("happybday.txt"); while (!inData.eof()){ inData.get(ch); cout<<ch; } inData.close(); cout<<" "<<endl; _getch(); system("cls"); cout<<"Thank you for using my program! Hope you enjoyed it!"<<endl; cout<<" -Jared Amos"<<endl; _getch(); } Now I just gotta find a replacement for the system("cls") function I replaced system("pause") with code that inserts 5 blank lines. (dont worry, I prototyped a fnct, so the code only had to be created once, and I call the function instead of the system pause) Link to comment Share on other sites More sharing options...
Addictgamer Posted January 24, 2010 Share Posted January 24, 2010 Good... When you compiled, did you make sure to choose release configuration if you're using msvc++ express or pro. Then upload the file out of the 'release' folder. See the word debug next to the green arrow? Click and select release. Link to comment Share on other sites More sharing options...
sciguy Posted January 26, 2010 Author Share Posted January 26, 2010 Yeah, I had figured that out... Attached is the release version of the program. after Acmex mentioned it, it hit me I was compiling in debug configuration.happybdayrelease.zip ========================================================================================================== Here is the code for my newest program, a en/decryption prog. Once I compile and test it, I will upload it if anyone wants a copy but can't compile it themselves. #include <iostream> #include <fstream> #include <iomanip> #include <string> using namespace std; char inputFile[50]; char outputFile[50]; char inMsg; int i; char key; char outMsg; string valida; string validb; int main(){ cout<<"Enter the input file"<<endl; cin>>inputFile; cout<<"Enter the output file"<<endl; cin>>outputFile; cout<<"Enter key"<<endl; cin>>key; i=0; ifstream MyFile(inputFile); ofstream MyOutFile(outputFile); while(!MyFile.eof()) { MyFile.get (inMsg); valida[i]=inMsg;//Assertion error occurred here outMsg=inMsg^key; validb[i]=outMsg^key; MyOutFile<<outMsg; i++; } MyFile.close(); MyOutFile.close(); cout<<"En/Decryption successfull, checking validity..."<<endl; if (valida==validb) cout<<"En/Decryption is valid"<<endl; else cout<<"En/Decryption is invalid, please try again"<<endl; return 0; } newest code, assertion error occurred at the comment Link to comment Share on other sites More sharing options...
Addictgamer Posted January 26, 2010 Share Posted January 26, 2010 Looks nice. I'll test it out when I can. Why did you use a char array? Link to comment Share on other sites More sharing options...
sciguy Posted January 27, 2010 Author Share Posted January 27, 2010 Ok, I got the program to work, (thanks to Anon and Addict), but it cuts off part of the end of the file, so the file after decryption is the same as the origional file, but with a few missing characters. Here's the code: #include <iostream> #include <fstream> #include <iomanip> #include <string> using namespace std; string inputFile; string outputFile; char inMsg; char key; char outMsg; char ch; string valida; string validb; ifstream MyFile; ofstream MyOutFile; int main(){ cout<<"Enter the input file"<<endl; cin>>inputFile; cout<<"Enter the output file"<<endl; cin>>outputFile; cout<<"Enter key"<<endl; cin>>key; i=0; MyFile.open(inputFile.c_str()); MyOutFile.open(outputFile.c_str()); while(!MyFile.eof()) { MyFile.get (inMsg); valida+=inMsg; outMsg=inMsg^key; validb+=outMsg^key; MyOutFile<<outMsg; } MyFile.close(); MyOutFile.close(); cout<<"En/Decryption successfull, checking validity..."<<endl; if (valida==validb) cout<<"En/Decryption is valid"<<endl; else cout<<"En/Decryption is invalid, please try again"<<endl; system("pause"); return 0; } here is the origional txt file's contents: Hello, this is a test file for the en/decryption file. If you can't read this after encryption, then it was a success! If you can read it after decryption, it was a success! If both, it was a success! So, tell me: did it work? ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 `~!@#$%^&*()-_=+/\|[]{}<>,.;:'" after encryption the contents of the output file are: yT]]^EYXBXBPETBEWX]TW^CEYTT_UTRCHAEX^_WX]T;xWH^DRP_ECTPUEYXBPWETCT_RCHAEX^_EYT_XEFPBPBDRRTBB;xWH^DRP_CTPUXEPWETCUTRCHAEX^_XEFPBPBDRRTBB;xWS^EYXEFPBPBDRRTBB;b^ET]]\TUXUXEF^CZ;psrutwvyx{z}|~a`cbedgfihkPSRUTWVYX[Z]\_^A@CBEDGFIHK ;;QOqonmMjlJL after decryption: Hello, this is a test file for the en/decryption file. If you can't read this after encryption, then it was a success! If you can read it after decryption, it was a success! If both, it was a success! So, tell me: did it work? ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 `~!@#$%^&*()-_== Link to comment Share on other sites More sharing options...
Addictgamer Posted January 27, 2010 Share Posted January 27, 2010 Ya...I'll take a look at it later and see if I can help you. Mouse didn't find a solution!? :0 Link to comment Share on other sites More sharing options...
Sonic322 Posted January 29, 2010 Share Posted January 29, 2010 It works woot Link to comment Share on other sites More sharing options...
Addictgamer Posted January 29, 2010 Share Posted January 29, 2010 It does sonic, but there are some glitches. Unless you meant that there is no more error when running it for you. Link to comment Share on other sites More sharing options...
sciguy Posted January 29, 2010 Author Share Posted January 29, 2010 which program? The birthday card prog should have no errors, all system/OS dependant functions have been removed. The encryption prog works, but is glitchy, a few bytes are missing from the end for some reason. May be the way I write to the file.. Could try to store the output to a string or array then write the whole thing to the file at the same time. For the next version (after I fix this one) I may have it so you type the message into the prog, it encrypts it, then stores it in a binary file. Then you can read the data from the file and decrypt it, viewing it solely in the prog. Link to comment Share on other sites More sharing options...
Sonic322 Posted January 30, 2010 Share Posted January 30, 2010 which program? You only have one program made. What do you mean "which program"? Link to comment Share on other sites More sharing options...
Addictgamer Posted January 30, 2010 Share Posted January 30, 2010 He made 2, the bday card and the encrypter/decrypter <_< Link to comment Share on other sites More sharing options...
sciguy Posted January 30, 2010 Author Share Posted January 30, 2010 but i only uploaded 1, glad it worked for you, sonic. If anyone can tell what is wrong with my en/decryption prog, feel free to post it. Link to comment Share on other sites More sharing options...
Acmex Posted February 7, 2010 Share Posted February 7, 2010 Are you using the *right* array. (I.E: Float, ect...) I think that would only affect numbers, though, but IDK. Link to comment Share on other sites More sharing options...
Recommended Posts