473,396 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

HELP Exiting a Function after an if statement!

36
I want the function to exit (NOT continue) if the encryptedMess.txt file does not exist!

Below is the code for this function and it is after line 15 where i need help:


Expand|Select|Wrap|Line Numbers
  1. //Process of Decyption
  2.  
  3. void Decrypt()
  4. {
  5.     char decrypted;
  6.     stringLoc =0;
  7.  
  8.         char ch;
  9.  
  10.  
  11.         ifstream encryptedMess("encryptedMess.txt");        //Open Encrypted File message
  12.  
  13.         if (!encryptedMess)
  14.         {
  15.             cout<<"Error opening the file"<<endl;
  16.  
  17.  
  18.         }
  19.         while (!encryptedMess.eof())
  20.         {
  21.             encryptedMess.get(ch);
  22.             decrypted = ch-difference;
  23.  
  24.             cout<<decrypted;
  25.         }
  26.         encryptedMess.close();
  27.         cout<<endl<<endl;
  28.  
  29. //Save to text File
  30.         ofstream decryptedMess;
  31.         decryptedMess.open("decryptedMess.txt", ios::out);
  32.         decryptedMess<<decrypted;
  33.         decryptedMess.close();
  34. }

Any help would be much appreciate!

Thanks
Mar 8 '08 #1
3 1406
Banfa
9,065 Expert Mod 8TB
Look up the return statement in any basic book on the language (or on the web)
Mar 8 '08 #2
atiq
36
Look up the return statement in any basic book on the language (or on the web)
Thank you for your reply!

i cant use a return statement because it is a void function. What alternative way can i achieve this? I would be grateful if you could provide the coding.

Thanks
Mar 8 '08 #3
Banfa
9,065 Expert Mod 8TB
i cant use a return statement because it is a void function. What alternative way can i achieve this? I would be grateful if you could provide the coding.
Yes you can, I repeat, look up the return statement in any basic book on the language.
Mar 8 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Tim Clacy | last post by:
When exiting function scope, which occurs first: a) destruction of local objects b) copy of value for return From disassembly of a debug target, it looks like the return value is copied before...
22
by: L. Westmeier | last post by:
Is there a way to have to exiting point in a void function? I don't want to exit the program but just this function. Any answers appreciated. L. Westmeier
4
by: Tarique Jawed | last post by:
Alright I needed some help regarding a removal of a binary search tree. Yes its for a class, and yes I have tried working on it on my own, so no patronizing please. I have most of the code working,...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
6
by: Pablo | last post by:
Hello, I am writing a windows application using C++ and BorlandBuilder 6 compiler. It is an event driven program and I need to create objects of some classes written by me. One of the classes...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
3
by: Stephen Torri | last post by:
Below is a class that is suppose to represent a segment of memory or a contents of a binary image (e.g. ELF executable). I have started to read Modern C++ Design and thought the best way to ensure...
3
by: WISEMANOFNARNIA | last post by:
I would like to prevent a user from exiting a page by clicking on links. the only way he should be able to exit is clicking on a 'save' button or a 'cancel' button. I can see that javascript is...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.