Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,175 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,379 people online right now. Registration is fast and FREE... Join Now!




need help with "cat" linux command in c++

 
Reply to this topicStart new topic

need help with "cat" linux command in c++

abig
9 Jul, 2008 - 01:24 AM
Post #1

New D.I.C Head
*

Joined: 9 Jul, 2008
Posts: 1

hi,
I need to merge some mp3 files in linux,
now I can write this command in linux command prompt :
CODE
cat a.mp3 b.mp3>>c.mp3

and I get c.mp3 file that composed of a.mp3+b.mp3
does anyone knows how to do it in c/c++ (I have many mp3 files to merge)

I tried some options like this:
CODE
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main ()
{
    
    "cat a.mp3 b.mp3>>c.mp3";
            
    return 0;
}

but it failed to do it.

thanks in advance
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Need Help With "cat" Linux Command In C++
9 Jul, 2008 - 01:26 AM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,504



Thanked: 67 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
Not exactly how I would do it... but this should fix your error biggrin.gif
cpp
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main () {

system("cat a.mp3 b.mp3>>c.mp3");

return 0;
}

User is offlineProfile CardPM
+Quote Post

Tom9729
RE: Need Help With "cat" Linux Command In C++
9 Jul, 2008 - 01:56 PM
Post #3

Debian guru
Group Icon

Joined: 30 Dec, 2007
Posts: 1,461



Thanked: 10 times
Dream Kudos: 325
My Contributions
Gah don't do it in a C++ program, do it in a shell script.
User is offlineProfile CardPM
+Quote Post

lanec42
RE: Need Help With "cat" Linux Command In C++
9 Jul, 2008 - 02:26 PM
Post #4

D.I.C Head
**

Joined: 25 Mar, 2008
Posts: 144


My Contributions
"system( )" does that for Linux?! I thought it would only work with Windows.
User is offlineProfile CardPM
+Quote Post

Cerolobo
RE: Need Help With "cat" Linux Command In C++
9 Jul, 2008 - 02:30 PM
Post #5

D.I.C Regular
Group Icon

Joined: 5 Apr, 2008
Posts: 440



Thanked: 31 times
My Contributions
Nope. system() is a standard C function. The results of running it depend on the OS though.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 10:39AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month