i want similar help
but i want the code to be in c++
if have modified this code and tried to use it but somehow its nt wrking...it ll b kind of sum1 to hlp me in dis...

Post the code you tried to write.

use ifstream

then :

int main()
{
     cout<<"Enter file name (with extension): "
     char filename[1024] = {0};
     cin >> filename;
   ifstream iFile(filename);
  ...//do some stuff
}

Looks ok to me. The only problem I see is that >> operator will not allow the file name to contain spaces. You need to use getlin() if you want spaces.

Why do you think the code you posted does not work?

Looks ok to me. The only problem I see is that >> operator will not allow the file name to contain spaces. You need to use getlin() if you want spaces.

Why do you think the code you posted does not work?

Thats getline() what Ancient Dragon wanted to say and dont worry you wont need it because filenames don't contain spaces in them and you are using it for files. ;)

>you wont need it because filenames don't contain spaces in them and you are using it for files.
I can create files on my computer which contain spaces in their filename, so in fact to be fully correct you'll need it.
But you're right in saying that the getlin() has to be getline() of course, remember that it is code `à la Ancient Dragon´ :P
(not an insult)

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.