---
title: "I need a C plus plus program which is work on"  
description: "I need a C plus plus program which is work on"  
author: "Anonymous User"  
published: 2012-12-05  
updated: 2012-12-05  
canonical: https://www.mindstick.com/forum/482/i-need-a-c-plus-plus-program-which-is-work-on  
category: "visual c++"  
tags: ["visual c++"]  
reading_time: 2 minutes  

---

# I need a C plus plus program which is work on

Hi every one\
\
I have a little [bit](https://www.mindstick.com/forum/33411/how-we-tell-programmatically-if-i-m-running-in-64-bit-jvm-or-32-bit-jvm) [knowledge](https://www.mindstick.com/forum/156160/what-is-google-knowledge-graph) in [C++](https://www.mindstick.com/blog/745/array-in-c-plus-plus),\
\
I need a C++ [program](https://www.mindstick.com/blog/12337/scaling-up-your-mentorship-program) which is work on:-\
1.the key [file](https://www.mindstick.com/articles/59/encrypting-and-decrypting-files-using-c-sharp) is automatically generated.\
2.Methods for read and write.\
3.file and [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp) [objects](https://www.mindstick.com/forum/145447/what-are-objects) are global.\
4.file will open in [binary](https://www.mindstick.com/forum/34709/please-write-a-program-for-decimal-to-binary-conversion-in-c-sharp) mode.\
\
Thanks

## Replies

### Reply by Vijay Shukla

thats your solution.\
#include <iostream.h>#include<stdio.h>#include <fstream.h>#include <conio.h>#include<stdlib.h>#include<io.h>fstream myfile;class key{ public: long a; char b; void open() { char st[50]; int roll,cl; randomize(); a =100000000 + rand()%10000000; //generating random no for Key File. b= 97 + rand()%26; myfile.open ("student.txt",ios::out | ios::binary); //opening file in write mode in binary format cout<<"Enter student name: "; gets(st); cout<<"Enter student's roll: "; cin>>roll; cout<<"Enter student's class: "; cin>>cl; myfile<<"\nStudent name: "<<st; myfile<<"\nStudent's roll: "<<roll; myfile<<"\nStudent's class: "<<cl; myfile <<"\nWriting this to a file.\n"; myfile <<"KEY FILE:-"<< b << a<<endl; //writing the key file in your file. myfile.close(); } void display() { char ch; cout<<"THE FILE WRITTEN AS:\n\n"; myfile.open("student.txt",ios::in | ios::binary); //opening file in write mode in binary format \
while(myfile) { myfile.get(ch); cout<<ch; } myfile.close(); }}stu;\
\
\
\
int main() { int ch; char c='y'; clrscr(); while(1) {\
cout<<"\nMENU......\n1.WRITE....\n2.READ....\n3.EXIT....\nENTER YOUR CHOICE....."; cin>>ch; switch (ch) { case 1: while(c=='y'|| c=='Y') { stu.open(); cout<<"Do you want to generate more keys.... Y/N\n"; cin>>c;\
} break; case 2: stu.display(); break; case 3: exit(0); default: cout<<"\nWrong choice entered..."; } } getch(); return 0;}\


---

Original Source: https://www.mindstick.com/forum/482/i-need-a-c-plus-plus-program-which-is-work-on

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
