dickiebird
Programmer
With the following code fragment, if I run the program as below , I get a Segmentation fault at the sprintf
But if I redefine cmdline as an array, instead of char * , it works OK
Why ????
Its me and pointers again, isn't it ?!?!?!
main(argc, argv)
int argc;
char **argv;
{
char *cmdline;
/* char cmdline[50]; */
struct msqid_ds buf;
int quiet, ok, error;
quiet = ((argc > 3) && (argv[3][1]=='q'));
strcpy(argv0, argv[0]);
ok = 1;
if(!quiet)
{
fprintf(stderr, "%s\n\n", "Running ...."
fflush(stderr);
if(!ok)
exit(-255);
}
if ( argc == 1 )
{
/* Exec master server in background */
sprintf(cmdline, "%s %d %d -q&", argv[0], CIMASTER, CIMASTER );
}
Your help and guidance is much appreciated
;-)
Dickie Bird
db@dickiebird.freeserve.co.uk
But if I redefine cmdline as an array, instead of char * , it works OK
Why ????
Its me and pointers again, isn't it ?!?!?!
main(argc, argv)
int argc;
char **argv;
{
char *cmdline;
/* char cmdline[50]; */
struct msqid_ds buf;
int quiet, ok, error;
quiet = ((argc > 3) && (argv[3][1]=='q'));
strcpy(argv0, argv[0]);
ok = 1;
if(!quiet)
{
fprintf(stderr, "%s\n\n", "Running ...."
fflush(stderr);
if(!ok)
exit(-255);
}
if ( argc == 1 )
{
/* Exec master server in background */
sprintf(cmdline, "%s %d %d -q&", argv[0], CIMASTER, CIMASTER );
}
Your help and guidance is much appreciated
;-)
Dickie Bird
db@dickiebird.freeserve.co.uk