4 Replies - 3637 Views - Last Post: 09 July 2008 - 03:30 PM Rate Topic: -----

#1 abig  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-July 08

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

Posted 09 July 2008 - 02:24 AM

hi,
I need to merge some mp3 files in linux,
now I can write this command in linux command prompt :
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:
#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

Is This A Good Question/Topic? 0
  • +

Replies To: need help with "cat" linux command in c++

#2 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5182
  • View blog
  • Posts: 26,889
  • Joined: 10-May 07

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

Posted 09 July 2008 - 02:26 AM

Not exactly how I would do it... but this should fix your error :D
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

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


Was This Post Helpful? 0
  • +
  • -

#3 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

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

Posted 09 July 2008 - 02:56 PM

Gah don't do it in a C++ program, do it in a shell script.
Was This Post Helpful? 0
  • +
  • -

#4 lanec42  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 229
  • Joined: 26-March 08

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

Posted 09 July 2008 - 03:26 PM

"system( )" does that for Linux?! I thought it would only work with Windows.
Was This Post Helpful? 0
  • +
  • -

#5 Cerolobo  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 53
  • View blog
  • Posts: 450
  • Joined: 05-April 08

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

Posted 09 July 2008 - 03:30 PM

Nope. system() is a standard C function. The results of running it depend on the OS though.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1