Jump to content

input name for text file (.txt)

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Amonijack

Amonijack

    Learning Programmer

  • Members
  • PipPipPip
  • 56 posts
string name;

    

    cout<<"put file's name : ";

    cin>>name;

    

    fstream file;

    

    file.open(name.txt);

file.open(name.txt); // this line not work

help ?

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
Strings are enclosed in double quotes, so I would assume you would do file.open(name + ".txt");
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users