Sauce
Junior Poster in Training
55 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
I don't have a Linux Box, but if there is a program that plays wave files you could call it with system(). Something like
system("WavePlayer cat.wav")
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
I don't have a Linux Box, but if there is a program that plays wave files you could call it with system(). Something like
system("WavePlayer cat.wav")
I dont think you can use the "System" command in linux. I'm pretty sure its a windows only command.
But what i think i would do is just piggy back off of another program (linux does this all the time) and is what i think vegaseat is refering to. I'd install a program like mpg123 (basic mp3 player) and "exec" the program with the "-q" (quiet) option. I know its not a wav file but mp3's are just better anyway.
Sauce
Junior Poster in Training
55 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
>I dont think you can use the "System" command in linux.
I don't know about the "System" command, but the system function is standard C, declared in stdlib.h.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
I stand corrected on the "system" function in C. Yeah i just looked it up to make sure. I just realized why i thought that. Not a C or C++ programmer anymore so its been a while since i've written much in it.
As far as feeling like its cheating, I understand why you would feel that way but keep in mind, at least from a linux stand point, using other programs to accomplish a small part of your program is a good idea. It helps keep programs smaller and creation of programs faster. Plus its nice not having to recreate the wheel everytime you need one.
Sauce
Junior Poster in Training
55 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
>I think it's cheating.
For theorists, cheating is an option. For the rest of us, it's a necessity. :)
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>The system call also makes it unportable by default.
That's irrelevant. You're trying to do something inherently non-portable, so you'll be using a non-portable solution no matter how you look at it. The trick is to separate the non-portable parts from the portable parts so as to make porting the program easier.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
Also, another comment on the whole cheatting thing. Ever heard of windows API calls? its another example (obvious not valid here) of program "cheating" being used to its fullest. Of course using other linux programs to do tasks for you is probably as close to using a windows api as i think is possible in linux.
I agree with Narue on the ports comment but you could also ask java's jvm what the os type is (i presume) and do both system calls in an if statement. I only recommend something like that when its just a small amount of code otherwise you could make your program fatter then it needs to be (just like adding code that reinvents the wheel).
Sauce
Junior Poster in Training
55 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
>you could also ask java's jvm what the os type is
Assuming the JVM is installed. Since this isn't the Java forum, we can't assume that it is.
>and do both system calls in an if statement
Okay, that covers two operating systems. Since there's a concern about portability, how do you propose dealing with the other dozen and a half systems? ;)
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
Sorry about the java post, thats my more active forum but i got bored and was posting over here too.
Well the concept will work, there are otherways to finger print the os.
Sauce
Junior Poster in Training
55 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0