file handling

0 Maham Ijaz · April 2, 2015
How to convert a txt file into exe file to run on command prompt ?

Post a Reply

Replies

Oldest  Newest  Rating
+1 Brian Reed · April 3, 2015
Hi Maham,

My guess is you want to read the contents of a text file and then display it as an output.
I only come to this conclusion, because you have File Handling as the subject.
My first thought otherwise was you wanted to make a executable from code that was written in a text file.
To be honest, I don't know for sure either way, or if it's even something completely different.

Can you explain in more detail what exactly it is you are trying to do?
If possible include what you have already attempted to do.


Cheers,
Brian 
0 Maham Ijaz · April 5, 2015
Brian the problem was that I wanted to create a c++ code which has the following steps:
1. Take the input from user
2. then input should converted into a txt file and then I want that this txt file is converted into an exe file 
how can file handling help  me in that ?
0 Homer Simpson · April 5, 2015
Sounds to me like you want to make a compiler...

http://www.amazon.com/Compilers-Principles-Techniques-Tools-2nd/dp/0321486811
+1 Brian Reed · April 5, 2015
Hi Maham,

It can't.

File handling will not help you to make executable files, as Homer alluded to you have to make your code (using a text editor) then process it through a compiler to make it executable. You can take input from a user, store it as a file, then retrieve it later, but not as an executable.

What have you programmed?
What programming tools do you have?

If you want to learn how to make executable programs you have come to a good place.
People here will help you get there, no matter what your skill level is.

Cheers,
Brian
0 kenny endowed · April 6, 2015
check this code 



#include<fstream>
#include<string>
using namespace std;
void getdata()
{
    string input,input2;
    ofstream fout("login.txt",ios::app);
    cout<<"pls enter your username and password to store"<<endl;
    getline(cin,input);
    getline(cin,input2);
    fout<<input<<"  "<<input2<<endl;
    fout.close();
}
void display()

{
      string input,input2,input4;
    ifstream fin("login.txt");

while(fin>>input>>input2)
{
     cout<<"enter your password to show ur data"<<endl;
            cin>>input4;
            if(input4==input2)
            {
    cout<<input<<"   "<<input2<<endl;
            }
}
fin.close();
}
int main()
{
    start:
    int input3;
    char input2[10];
    char input4[10] = "*";
    cout<<"ENTER 1 TO CREATE NEW DATA\nAND TWO TO DISPLAY DATA"<<endl;
    cin>>input3;
    switch(input3)
    {
    case 1:
      getdata();
      goto start;
    }
    case2:
        {
    display();
    goto start;
        }
    return 0;
}
0 Maham Ijaz · April 9, 2015
Thanks Brian reed and kenny endowed :)
  • 1

C++

107,336 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator