Teen Programmers Unite  
 

 

Return to forum top

input a file's address on the disk (C++)

Posted by PavalDaniel [send private reply] at April 13, 2002, 12:59:06 PM

I want to make a krypting program. The user must wtite the address of the file. How do I do that?

Posted by CodeRed [send private reply] at April 13, 2002, 01:15:05 PM

what do you mean by "address on the disk"?

Posted by metamorphic [send private reply] at April 13, 2002, 01:30:12 PM

if you mean the directory, simpley create a string variable or a char array and get the users input with cin >>. then just use that variable as a your fopen stream path.

if you mean address such as in hard disk head and cylinder location, i don't think thats possible, well of course it is. but thats not the point.

Marc

Posted by PavalDaniel [send private reply] at April 13, 2002, 03:37:30 PM

I meant the directory as metamorphic thought. Thanks.

Posted by metamorphic [send private reply] at April 13, 2002, 07:05:22 PM

i cant think what the exact coding to get the file is, search for fstream for more info

Posted by CodeRed [send private reply] at April 13, 2002, 07:40:59 PM

char* filename;
cout << "Enter filename";
cin >> filename;

ifstream getData;
if(!getData.open(filename)) cout << "File does not exist";
//else the file is opened

Posted by metamorphic [send private reply] at April 13, 2002, 08:36:13 PM

dont forget your headers (:

Posted by vikram_1982 [send private reply] at April 14, 2002, 04:38:24 AM

Why dont u try getting the address using command line arguments?.... something similar to the COPY , MOVE etc commands in DOS(if u have worked with DOS!!!)

Posted by metamorphic [send private reply] at April 14, 2002, 09:03:05 AM

He means get a file as in the user needs to choose a file, not the file thats being run. you could maybe use command line params, but it would take longer than needed. Especially when you can just use ifstream.

Posted by vikram_1982 [send private reply] at April 14, 2002, 09:15:04 AM

ya, metamorphic is right

Posted by CodeRed [send private reply] at April 14, 2002, 04:07:58 PM

How is this a "krypting program"?

Posted by metamorphic [send private reply] at April 14, 2002, 06:16:52 PM

so that the user can enter the file to 'krypt' maybe?

Posted by vikram_1982 [send private reply] at April 14, 2002, 09:51:15 PM

What Krypting algorithm are u using???

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.