Welcome, Guest. Please login or register.

Author Topic: Simple C programming question.  (Read 1977 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: Simple C programming question.
« on: February 25, 2003, 12:04:41 PM »
There is an ANSI C function called system() in the stdlib.h header (I think). It runs a synchronous (AFAIR) command at the console, eg

#include
#include

int main()
{
    puts("Launching multiview!");
    system("SYS:Utilities/Multiview WINDOW");
    return 0;
}

If sucessful, the above C program should run multiview with a blank window.

I use something like this for opening debug files I generate inside my own code, so can assure you it works ;-)

-edit-

AFAIK, a.out is just the default executble name for the generated program. Check the docs for info on how to set the executable name that gcc produces. In any event, try running it at the shell and see what happens. Hopefully it's just your program...
Sorry if this seems a bit scant, I had scripts set up for all this stuff yonks ago and forgor simple things like that ;-)
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show all replies
Re: Simple C programming question.
« Reply #1 on: February 25, 2003, 12:30:54 PM »
Jolly good ;-)

A quick point -  always include the appropriate headers. If you don't, when the compiler sees you use a new function for the first time, it assumes that usage is the correct prototype for the function and will complain if you use it differently later. Big problem for variable argument length functions like printf().
int p; // A