Text editor

This is a discussion on Text editor within the C++ Programming forums, part of the General Programming Boards category; I was wondering if it would be possible to open up the last used file whenever my prog starts?...

  1. #31
    Registered User L_U_K_E's Avatar
    Join Date
    Apr 2006
    Posts
    106
    I was wondering if it would be possible to open up the last used file whenever my prog starts?

  2. #32
    Registered User
    Join Date
    Nov 2005
    Posts
    545
    Here's an easy way round that:
    save the name of the last used file name when the program ends in another file and hence open the last used file.

    I should write a book:
    "Practical Thinking From A Noob To A Noob"

  3. #33
    Registered User L_U_K_E's Avatar
    Join Date
    Apr 2006
    Posts
    106
    i keep getting this message "..." undeclared [first use this function]. What does it mean by that???

  4. #34
    Registered User L_U_K_E's Avatar
    Join Date
    Apr 2006
    Posts
    106
    I got the nameof last used file output sorted but how do i get my prog to search for that file and open it???

  5. #35
    Registered User
    Join Date
    Nov 2005
    Posts
    545
    read into the saved name of the file with a string and then use that exact string to open the file...just like you got a user to enter the name into a string.

  6. #36
    Registered User L_U_K_E's Avatar
    Join Date
    Apr 2006
    Posts
    106
    I just get an error when i try to do that so heres my code tell me whats going wrong:
    Code:
    ifstream d_file("Txt_log.txt");
                getline(cin,txt);
                ifstream e_file(txt);
                getline(cin,txtt);
                cout<< txtt;

  7. #37
    Registered User L_U_K_E's Avatar
    Join Date
    Apr 2006
    Posts
    106
    could someone tell me wahts the matter with the code above?

  8. #38
    Registered User
    Join Date
    Nov 2005
    Posts
    545
    Code:
    ifstream d_file("Txt_log.txt");
                getline(cin,txt);
                ifstream e_file(txt.c_str());
                getline(cin,txtt);
                cout<< txtt;
    Try that...

  9. #39
    Registered User
    Join Date
    Apr 2005
    Posts
    76
    well im kinda a newb too... but it looks to me that you have to do this
    Code:
    ifstream d_file("Txt_log.txt");
                getline(d_file,txt);
                ifstream e_file(txt.c_str());
                getline(e_file,txtt);
                cout<< txtt;
    From your code... your using getline as to get input from the user... that what CIN buffer is for...

    But if you want to get input from a file... u use the file name instead, as the buffer...

  10. #40
    Registered User L_U_K_E's Avatar
    Join Date
    Apr 2006
    Posts
    106
    Still not working, thanx though.

  11. #41
    Registered User L_U_K_E's Avatar
    Join Date
    Apr 2006
    Posts
    106
    Can someone plz help me?????

  12. #42
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Quote Originally Posted by L_U_K_E
    Can someone plz help me?????
    Possibly if you show the code that doesn't work.
    Kurt

  13. #43
    Registered User
    Join Date
    Apr 2005
    Posts
    76
    yes... what specifically isn't working?

  14. #44
    Registered User L_U_K_E's Avatar
    Join Date
    Apr 2006
    Posts
    106
    Could someone ave a lokk at this code im trying to make it copy the text from one file and paste it into another...
    Code:
    cout<<"Please enter the directory and filename and extension: ";
                      getline(cin,x);
                      ifstream a_file(x.c_str());
                      getline(a_file,a);
                      cout<<"Please enter the directory and filename and extension of the second file: ";
                      getline(cin,c);
                      ofstream b_file(c.c_str(),ios::app);
                      cout<< a;
                      cin.get();
                      cin.get();
                      system ("cls");
                      break;

  15. #45
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    if you change
    Code:
    cout<< a;
    to
    Code:
    b_file<< a;
    this program would append the first line of a_file to b_file.
    Kurt

Page 3 of 4 FirstFirst 1234 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating very simple text editor using c
    By if13121 in forum C Programming
    Replies: 9
    Last Post: 10-19-2010, 05:26 PM
  2. C++ For Text Editor?
    By bmroyer in forum C++ Programming
    Replies: 12
    Last Post: 04-05-2005, 02:17 AM
  3. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 03:49 PM
  4. help about text editor
    By nag in forum C++ Programming
    Replies: 2
    Last Post: 04-24-2003, 11:45 AM
  5. Making a text editor
    By neandrake in forum C++ Programming
    Replies: 5
    Last Post: 02-26-2002, 10:43 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21