ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi,
i'm trying to learn some c++ and have to write a program that copies a binary file to floppy. the book i'm learning with offers the folowing solution. but obviously it's for windows and i couldn't get it working on my box though i tried several times with various changes. everything compiled well but didn't work :-). all i get is: Exclaim: Exercise25 <file>. (anyway i don't know what that's good for.) how do i get that going? a good advice is much appreciated, thanks
jens
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
just suppose that,
input the command: copy c:\file.txt
so, the string "indatei" is "c:\file.txt".
after execute the code "strcat(outdatei,indatei);"
the string "outdatei" becomes "A:\c:\file.txt".
then,when executing the code
"ofstream outputf(outdatei, iosut | ios::binary);"
the output path now is "A:\c:\file.txt".
obviously, the output path is wrong.
Hey! remember that in linux there's it's not an A: device, floppy its located on /mnt/floppy and has to be mounted: i don't know any functions to check that floppy is mounted, but you can always call something like:
system(" mount floppy");
which does a 'mount floppy' call from a C program, then try to open the file with a directory of type "/mnt/floppy/whatever.txt"
unfortunately the 'system("mount floppy")' does not work. (compiler takes it as an implicit declaration of function). but in general that was what my question was about: how to: mount -t /dev/fd0 /media/floppy or similar. so if someone has an idea of that - would be great. bye
jens
great! that seems to work. only trouble is that only 'root' is allowed to run that mount command. i guess i'll find out myself how to fix that.
muchas gracias por otra vez! and many thanks to wwnn1, naturally you were right about the name of the output file. cheers, jens
worth remembering that "mount floppy" won't work on all systems - it would depend on there being this entry in the system's /etc/fstab:
/dev/fd0 /mnt/floppy auto ro,user,noauto 0 0
(or similar). the "user" option, btw, allows non-root users to mount the device. since this is only an example program, i guess you can change it to suite your systems fstab configuration anyway
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.