Hey there,

I am attempting to open Firefox using C++ on Linux (Ubuntu). However, I get an segmentation fault. What am I doing wrong, and what should I do?

std::cout << system("/usr/bin/firefox") << std::endl;

/usr/bin/firefox works in commandline and when I run this program in debug mode in Netbeans, firefox starts like it should.

I hope to hear from you.

Kind regards,

Schoorsteen

try running that system function on a line all by itself.

system("/usr/bin/firefox");

Gives the same result.

I'm sure this is not helpful, but as a data point for you this runs fine for me.

#include <iostream>
#include <cstdio>
#include <cstdlib>

int main()
{
  system("/usr/bin/firefox");
 
  return 0;
}

Dave

Alright, thank you very much. Strangely enough, running the code with netbeans in execution mode gets me a Segmentation Fault, but if I build it and then run it, it works fine.

Anyone got a clue how this is possible? Or perhaps suggestion what IDE I should use instead?

Code::Blocks is a good one.

I use KDevelop4.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.