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 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.
Jump to PostWell if you're using the antiquated version of Turbo C, it probably won't like
std::string
.My immediate advice would be to pretend you're writing this in c. However, your professor is probably expecting some bastardized version of c++ and c.
All 19 Replies
tux4life 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
tux4life 2,072 Postaholic
tomtetlaw -1 Posting Pro
ss2602 0 Newbie Poster
23.12.2012 22 Newbie Poster
tux4life 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
tux4life 2,072 Postaholic
tux4life 2,072 Postaholic
ss2602 0 Newbie Poster
tux4life 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.