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...

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)

This article has been dead for over six months. Start a new discussion instead.