Food Clan .::. Zombie Assassins
image Navigation image
 
· Search Our Site

· Join [ZÅ]

Important Links
· Home
· Special Requests
· Allies & Friends

Features
· Newsletter
· Fan Fiction
· YouTube Page
· Hall of Fame

Rules & Information
· Website Rules
· Membership Rules
· Server Rules & Info
· Classic Server Password Test
· The History of [ZÅ]
· Site & Server Admins
· Staying Safe Online


Other
· News Categories
· Downloads
· Photo Gallery
· Hall of Shame
· I DON'T THINK RAZ IS GOD
 
image image
image Last Seen Users image
 
· [ZÅ]SlimJim 1 day
· [ZÅ~V]Stuntman 3 days
· [ZÅ]Noobo 3 weeks
· [LÅZY]LazyTarget 6 weeks
· [ZÅ~V]DrkInferno12 weeks
· [ZÅ]Riptide22 weeks
· ZA Flax22 weeks
· [ZÅ]ODST-LoL26 weeks
· [ZÅ]JP27 weeks
· lkshadow30 weeks
· [ZÅ]MasterA41 weeks
· [ZÅ]Giants41 weeks
· [ZÅ]Dudeman41 weeks
· [ZÅ]Link-MC--LoL-CSGO43 weeks
· [ZÅ]Razberry43 weeks
· [ZÅ]Innervision47 weeks
· [ZÅ~V]Phoenix50 weeks
· [ZÅ~V]BrickSquad61 weeks
· {FC}Cookie64 weeks
· [ZÅ]Bvigil67 weeks
· [ZÅ~V]Boxhead68 weeks
· [ZÅ]Vlexis74 weeks
· {FC}Wings74 weeks
· [ZÅ~V]Buck76 weeks
· {FC~V}Coyote144 weeks
· [ZÅ~V]TheHatofLove150 weeks
· Kennan157 weeks
· [ZÅ]Paradox-MC-158 weeks
· zuko174 weeks
· A§H»ĴΘΘĶ181 weeks
· [ZÅ]Vaxjo184 weeks
· coldplay99184 weeks
· [ZÅ~V]RAGE184 weeks
· samtheman32189 weeks
· [ZÅ]ninja189 weeks
· [ZÅ]Code189 weeks
· FRINGE190 weeks
· [ZÅ]Leve190 weeks
· [ZÅ~V]Ezrab190 weeks
· BMF190 weeks
· MRBILL190 weeks
· [ZÅ~V]Hercules192 weeks
· ginny18231 weeks
· [ZÅ~V]Cloverton269 weeks
· [ZÅ]Carnage-WoWs285 weeks
· [ZÅ]Mist-Stn286 weeks
· theatticus294 weeks
· [ZÅ~V]Star298 weeks
· [ZÅ~V]Neo302 weeks
· [ZÅ]Saviour310 weeks
· [ZÅ~V]Irock23311 weeks
· [ZÅ]Revenge-Stn321 weeks
· Habu327 weeks
· [ZÅ~V]Althor338 weeks
· Founder~[ZÅ~V]Trunks338 weeks
· [ZÅ~V]Llamas344 weeks
· [ZÅ~V]Bagels346 weeks
· Founder~[ZÅ~V]Coke352 weeks
· Teemo353 weeks
· Rabidtaco353 weeks
· [ZÅ~V]BlackAdder-LoL360 weeks
· [ZÅ~V]Ice368 weeks
· Hav375 weeks
· [ZÅ~V]Huggy380 weeks
· [ZÅ~V]RealmHunter381 weeks
· [ZÅ]Tulip-LoL-CSGO382 weeks
· [ZÅ~V]Pizzleini387 weeks
· [ZÅ~V]Martyr388 weeks
· Java394 weeks
· SpartanJaz398 weeks
· [ZÅ~V]Luna398 weeks
· [ZÅ~V]Kíttý412 weeks
· [ZÅ~V]Sinder414 weeks
· arbiterspar420 weeks
· Bacon425 weeks
· Magnum429 weeks
· H4WK437 weeks
· [Lagzy]448 weeks
· [ZÅ]Whatmesage455 weeks
· [ZÅ~V]Suika458 weeks
· Zidane458 weeks
· [ZÅ~V]Pieeater459 weeks
· [ZÅ~V]Numpty459 weeks
· [ZÅ]Swicey459 weeks
· [ZÅ~V]ChAr459 weeks
· Smile.jpg459 weeks
· Ronald459 weeks
· Bane459 weeks
· [ZÅ]Soulcyon-LoL459 weeks
· TacoCookie459 weeks
· [ZÅ]Buckwheat459 weeks
· [ZÅ~V]PirateKing-LoL460 weeks
· ShawnPeezy471 weeks
· [ZÅ~V]JOSEPH5485 weeks
· xXKrysisXx490 weeks
· Chuck491 weeks
· Homeless492 weeks
· Warrior493 weeks
· [ZÅ~V]Smurf495 weeks
· JunkyMonkey495 weeks
 
image image
image View Thread image
 
 Print Thread
Programming Help
Caesar
#1 Print Post
Posted on 11/18/2013 15:17:54
Member


Posts: 179
Joined: 22.08.13

Okay, so for my Programming Class, we're doing C++ Caesar Cipher. I already have the whole thing written (With a lot of Else if Statements), but now we're trying to add functions to the program. I doubt any of you (Unless you're in college) have code blocks so I have decided to post the program here (Warning it's long) and I ask that someone help me :(




Download source  Code
//***********************************************~********************
//Caesar Cipher. This program out puts a simple letter substitution
//cipher used by Julius Caesar. ROT13 replaces a letter with 13
//letters that come after in the alphabet.
//*********************************************************************
#include <fstream>
#include <iostream>
#include <string>

using namespace std;
char caesar( char );

int main()
{
   string letter;
   ofstream outData;
   ifstream inData;
   char character;

 cout << "Enter file name" << endl;
 cin >> letter;

 //open file
 inData.open (letter.c_str());
 outData.open ("note.out");

 inData >> character;
 character= toupper(character);


 while(inData)
 {
     if (character == 'A')
       {
           outData << "N";
       }


      else if (character == 'B')
       {
           outData << "O";
       }

     else if (character == 'C')
       {
           outData << "P";
       }

      else if (character == 'D')
       {
           outData << "Q";
       }

     else  if (character == 'E')
       {
           outData << "R";
       }

      else if (character == 'F')
       {
           outData << "S";
       }


      else if (character == 'G')
       {
           outData << "T";
       }


      else if (character == 'H')
       {
           outData << "U";
       }


      else if (character == 'I')
       {
           outData << "V";
       }


      else if (character == 'J')
       {
           outData << "W";
       }


    else   if (character == 'K')
       {
           outData << "X";
       }

      else if (character == 'L')
       {
           outData << "Y";
       }

     else  if (character == 'M')
       {
           outData << "Z";
       }

      else if (character == 'N')
       {
           outData << "A";
       }

     else  if (character == 'O')
       {
           outData << "B";
       }

     else  if (character == 'P')
       {
           outData << "C";
       }

      else if (character == 'Q')
       {
           outData << "D";
       }

      else if (character == 'R')
       {
           outData << "E";
       }

     else  if (character == 'S')
       {
           outData << "F";
       }

     else  if (character == 'T')
       {
           outData << "G";
       }

      else if (character == 'U')
       {
           outData << "H";
       }

     else  if (character == 'V')
       {
           outData << "I";
       }

     else  if (character == 'W')
       {
           outData << "J";
       }

     else  if (character == 'X')
       {
           outData << "K";
       }

     else  if (character == 'Y')
       {
           outData << "L";
       }

     else  if (character == 'Z')
       {
           outData << "M";
       }

       else
       {
        cout << "Incorrect input" << endl;
        }


 inData >> character;
 }



 return 0;
}



Edited by ninja on 11/18/2013 18:24:02
My name is Julius Augustus Octavianus Joseph Vissarionovich Stalin Brutus

I am DrkInferno in case you didn't know. booooooo (didn't change that) Actually the other way around.
 
Send Private Message
Caesar
#2 Print Post
Posted on 11/18/2013 15:18:26
Member


Posts: 179
Joined: 22.08.13

WTF?! Those smiley faces should be semi colons!
My name is Julius Augustus Octavianus Joseph Vissarionovich Stalin Brutus

I am DrkInferno in case you didn't know. booooooo (didn't change that) Actually the other way around.
 
Send Private Message
Vlexis XII
#3 Print Post
Posted on 11/18/2013 15:57:15
User Avatar

Admin


Posts: 1199
Joined: 16.07.13

I am of no help here because I know nothing about programming, but I lol'd at the winking smiley faces. xD

To get rid of them, edit the reply and check the box that says "Disable Smileys." :P
Edited by Vlexis XII on 11/18/2013 15:58:05
I like owls. Do you like owls? (@v@)
i.imgur.com/9rXmQht.gif
i.imgur.com/EnB68Nm.gif
 
Send Private Message
Target
#4 Print Post
Posted on 11/18/2013 16:13:06
User Avatar

Numpty


Posts: 1425
Joined: 19.07.12

I have to start a refresher course on C++; Just a thought..wouldn't it be easier to have conditional statements so there's not 500 lines? Also, wuts with the outdata? I thought it was cout to print the data..

/admittedly my memory is a bit hazy on the topic..
Edited by Target on 11/18/2013 16:13:56
Lasso Lassie's Legendary Legless Lego-Legolas!

i1207.photobucket.com/albums/bb478/valkeryn/lazysig_zps804bf150.png

24.media.tumblr.com/d9b0d46416440eea032de7e7d7a6a9b6/tumblr_mnh2vqRK211rw1wnno1_400.gif

s20.postimg.org/l0a8zydvx/Wurt_The_Furk.jpg
 
Send Private Message
ZA Bvigil
#5 Print Post
Posted on 11/18/2013 16:21:55
User Avatar

Admin


Posts: 2161
Joined: 15.11.10

There are multiple methods for outputting data I personally use cout and ya i'd suggest using a conditional statement if you'd like I can find my version of this program but with conditional statements that make it like only 3 lines long
also i'm a bit confused by your question that you need help with I can help you as i'm a comp science major but again not quite sure what you're asking
i.imgur.com/ksbUZ.jpg

i1141.photobucket.com/albums/n590/4sexy/ragecomic.png
 
Send Private Message
SpartanJaz
#6 Print Post
Posted on 11/18/2013 16:38:11
User Avatar

Junior Member


Posts: 34
Joined: 13.08.12

I might be wrong but I seem to remember functions being initialized with:
int FunctionName()

So for example, initializing the OpenFile() function would be done as follows:
int OpenFile()
{
inData.open (letter.c_str());
outData.open ("note.out"Wink;

inData >> character;
character= toupper(character);
}

Initialize the function in this way before int main.

You can then call the function within int main by simply typing
OpenFile();


Haven't got Visual installed atm though so can't test it. That's the method I believe I've used in the past though.(Though I haven't even looked at C++ for at least a couple months now)

Oh, and you might have to change int appropriately for the content of the function.(So if you're returning a value which an int is not suitable for, substitute int for something else. (So my example may be incorrect, so don't copy and paste it Pfft)
 
Send Private Message
Vulture
#7 Print Post
Posted on 11/18/2013 17:11:54
User Avatar

Newbie


Posts: 0
Joined: 25.08.12

I would help if I was an expert at program language, but I'm afraid I can't help as I'm weak at it. Sorry. :/
i.imgur.com/hatTDjw.png

i.imgur.com/LvSfNPj.png Proud to be in the Jajaja group!
 
Send Private Message
Mist
#8 Print Post
Posted on 11/18/2013 17:59:52
User Avatar

Numpty


Posts: 1242
Joined: 22.07.13

I would recommend pm-ing or talking with Vulture. Vulture is extremely smart and is very familiar with that stuff and i spam him all the time about my pc problems/questions. Also, i didn't read Vult's post above so if he said something like "i have no idea" well then i have NO idea what to do LOL maybe try like a carnage or someone smart like that idk
 
Send Private Message
ninja
#9 Print Post
Posted on 11/18/2013 18:15:38
User Avatar

Super Admin


Posts: 4174
Joined: 15.11.10

I have Codeblocks and know some basic C++, but it's hard to help if you don't format your code properly, and you don't ask any questions.

E: I re-formatted your code so that it's readable.

Have you thought about generalising your code? At the moment, it will only shift 13 places.

Did you know that you can treat characters as integers (using ascii), so that you don't have to use loads of if statements?
Edited by ninja on 11/18/2013 18:51:08
steamsignature.com/status/english/76561198019046882.png

i.imgur.com/EzcOjDS.png
My brain is open.
- Paul Erdős
 
Send Private Message
ZA Bvigil
#10 Print Post
Posted on 11/18/2013 19:12:49
User Avatar

Admin


Posts: 2161
Joined: 15.11.10

what ninja said is the method i'd suggest treating characters as integers is the best way to do a function like this
i.imgur.com/ksbUZ.jpg

i1141.photobucket.com/albums/n590/4sexy/ragecomic.png
 
Send Private Message
ninja
#11 Print Post
Posted on 11/18/2013 20:25:35
User Avatar

Super Admin


Posts: 4174
Joined: 15.11.10

ZA Bvigil wrote:
what ninja said is the method i'd suggest treating characters as integers is the best way to do a function like this

Yes, it works very neatly.

I hadn't written a Caesar shift program in C++ before (I mostly use Python), so I just had a go, and got it down to about 20 lines of code using that technique. Most of that is set-up and text I/O, too - the actual encoding is about 3/4 lines (although it uses loops and modular arithmetic, which you may not have met).
steamsignature.com/status/english/76561198019046882.png

i.imgur.com/EzcOjDS.png
My brain is open.
- Paul Erdős
 
Send Private Message
Vulture
#12 Print Post
Posted on 11/18/2013 23:58:50
User Avatar

Newbie


Posts: 0
Joined: 25.08.12

Mist wrote:
I would recommend pm-ing or talking with Vulture. Vulture is extremely smart and is very familiar with that stuff and i spam him all the time about my pc problems/questions. Also, i didn't read Vult's post above so if he said something like "i have no idea" well then i have NO idea what to do LOL maybe try like a carnage or someone smart like that idk


Did you not read post #7? lol
i.imgur.com/hatTDjw.png

i.imgur.com/LvSfNPj.png Proud to be in the Jajaja group!
 
Send Private Message
Mist
#13 Print Post
Posted on 11/19/2013 00:10:15
User Avatar

Numpty


Posts: 1242
Joined: 22.07.13

Vulture wrote:
Mist wrote:
I would recommend pm-ing or talking with Vulture. Vulture is extremely smart and is very familiar with that stuff and i spam him all the time about my pc problems/questions. Also, i didn't read Vult's post above so if he said something like "i have no idea" well then i have NO idea what to do LOL maybe try like a carnage or someone smart like that idk


Did you not read post #7? lol

LMFAO! nope lol~hahaha~
 
Send Private Message
ninja
#14 Print Post
Posted on 11/19/2013 22:12:58
User Avatar

Super Admin


Posts: 4174
Joined: 15.11.10

Did you sort it out, or do you not actually want help?
steamsignature.com/status/english/76561198019046882.png

i.imgur.com/EzcOjDS.png
My brain is open.
- Paul Erdős
 
Send Private Message
Jump to Forum:
 
imageimage
image Login image
 
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
 
image image
image Shoutbox image
 
You must login to post a message.

Drkinferno
04/30/2026 16:29:13
not dead

stunt1man
02/17/2026 17:22:06
Still alive. ~B_Slap~

Hobo
02/16/2026 21:44:26
Wassup gang ~craptacular~

stunt1man
01/30/2026 12:29:22
Anytime I post something in the thread, it's not visible.

stunt1man
01/27/2026 20:09:23
The ISP blocked you.

Target
12/29/2025 21:50:19
Ditto! Grin

stunt1man
12/28/2025 16:40:54
Happy new year. ~noob~

Target
11/27/2025 12:34:23
Happy Thanksgiving :3

Target
10/31/2025 09:30:28
Happy Halloween everyone! Smile

Target
10/25/2025 09:09:20
https://www.youtub
e.com/watch?v=AMGJ
7OMqyvI woah

stunt1man
10/24/2025 16:32:18
Hola Papi!

Link
09/29/2025 23:37:58
OMG HI GUYS!!! I was able to finally log in after so many years!!! I hope everyone is doing well in life! Man, time flies!

RazNinjaMike
09/26/2025 06:40:34
if you dont got discord, go get it. its great for chatting as well Cool

stunt1man
09/21/2025 11:10:02
~Nana~

Drkinferno
09/15/2025 20:05:42
no, I log in time to time

stunt1man
09/07/2025 12:26:37
~argue~

Innervision
08/30/2025 14:52:46
Hope everyone is doing well, good ol shoutbox lol Smile

stunt1man
07/31/2025 18:41:06
I had replied to the thread and it broke. ~ban?~

FC_SlimJim
06/22/2025 20:43:11
idk what happened with that thread cause i cant access it either lol

Drkinferno
05/25/2025 20:05:26
I can't access it either lol

 
image image
image image