i want the user to enter the name of the file to open and i want it in c++, i have seen a similr work done in vc but i m nt abl 2 implement da same in c++
ss2602
0
Newbie Poster
Recommended Answers
Jump to PostCould you post your own try first?
Jump to PostTomtelaw, you forgot to add the following line to your code:
#include <string>
:P
Jump to PostYou might also want to prompt the user for the file's path. This way, you'll have a second variable, or you'll have to also tell the user to include the path when he inputs the file name. If you go for the former, you'll also need some string concatentation.
Jump to PostTo start: a foreword on the use of gets()
char name[100]; ifstream infile; cout<<"Enter filename>>"; gets(name); infile.open(name);
this is my code segment that is not working. i suppose i am missing something
Damn, how could I have overlooked this:
gets(name);
To the OP, and everyone else who …
Jump to Posttux4life,
I appreciate your time. I guess, from the OP's post that he/she has old compiler.
>include string.
-- is unnecessary when we include iostream and imports std namespace.
All 19 Replies
mvmalderen
2,072
Postaholic
ss2602
0
Newbie Poster
tomtetlaw
-1
Posting Pro
ss2602
0
Newbie Poster
tomtetlaw
-1
Posting Pro
ss2602
0
Newbie Poster
tomtetlaw
-1
Posting Pro
mvmalderen
2,072
Postaholic
tomtetlaw
-1
Posting Pro
ss2602
0
Newbie Poster
23.12.2012
22
Newbie Poster
mvmalderen
2,072
Postaholic
kvprajapati
commented:
Proff. Tux teaching.
+7
Nick Evan
commented:
A cookie for the effort :)
+22
Tom Gunn
commented:
good
+7
kvprajapati
1,826
Posting Genius
Team Colleague
mvmalderen
2,072
Postaholic
mvmalderen
2,072
Postaholic
ss2602
0
Newbie Poster
mvmalderen
2,072
Postaholic
ss2602
0
Newbie Poster
iamthwee
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.