Thread: txtfile title=char and concatenating=string, must convert string to char =( need help

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    19

    txtfile title=char and concatenating=string, must convert string to char =( need help

    well first of all, I'm using windows and new compiler(Bloodshed DevCpp YAY )

    well here's my situation i cant really continue unless there's a solution...

    The problem is under function void make_file. I tried using the loop thing and lib string isn't really helping(or i just didnt know the potential of it) anyways i hope someone can help me. i cant make the file name unless its char, and i placed the supposed to be file name in struct name.data[1] and its a string(why string cuz i concatenated it). and converting it to char is probably my first prob. Mind that my problem is only focused on function void make_file. others works fine. but suggestion swill be accepted, if your wondering what the hell i;m doing... just imagine cut file from one directory like "c:\" to "d:\" with file creating, deleting files and extras

    Thanks in advance

    Code:
    #include <iostream>
    #include <fstream>
    #include <string>
    using namespace std;
    // string data 1 is from/old and data 2 is to/new kk?
    struct info{string data[2];}location,name,msg;
    
    void create();
    void open();
    void del();
    void make_file();
    
    
    int main()
    {
        int select = 0;
        while(select<1||select>4)
        {
            system("cls");
            cout<<"Select File Option: \n";
            cout<<"[1] - Create File \n";
            cout<<"[2] - Open File \n";
            cout<<"[3] - Delete File \n";
            cout<<"[4] - Exit \n";
            cout<<"Execute: ";
            cin>>select;
            switch(select)
            {
                case 1: create();
                        break;
                case 2: open();
                        break;
                case 3: del();
                        break;
                case 4: system("cls");
                        cout<<"Thank you... \n";
                        cin.get();
                        break;
                default: 
                        cout<<"Please Enter Correctly";
                        system("pause");
                        break;
            }
        }
        system("pause");
        return 0;
    }
    
    void create()
    {
        string filename;
        system("cls");
        cout<<"Create File: \n\n";
        cout<<"LocatioN: ";
        cin>>location.data[1];
        cout<<"\nFilename: ";
        cin>>filename;
    //concat found here 
        filename += ".txt";
        name.data[1] = filename;
        cout<<"\nMessage: ";
        cin>>msg.data[1];
        
        make_file();
        
    }
    
    void open()
    {
        system("cls");
        
    }
    
    void del()
    {
        system("cls");
    }
    
    // here's the problem...
    void make_file()
    {
        char we[50];
        we=name.data[1];
        cout<<we;
    }
    Last edited by jazzglenn421; 09-12-2010 at 02:13 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The UNIX System Interface
    By rrc55 in forum C Programming
    Replies: 1
    Last Post: 10-20-2009, 05:56 PM
  2. Inheritance Hierarchy for a Package class
    By twickre in forum C++ Programming
    Replies: 7
    Last Post: 12-08-2007, 04:13 PM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. Something is wrong with this menu...
    By DarkViper in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 11:06 PM
  5. Strings are V important...
    By NANO in forum C++ Programming
    Replies: 15
    Last Post: 04-14-2002, 11:57 AM