🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: sun.tech
Article #2

Sun Pascal: Pascal calls C

#2
From: Jason Freund
Date: Mon, 27 Aug 1990 23:23
44 lines
1877 bytes
	I am calling a C routines from a Pascal program to (among other things)
change directories.  I am using several other C routines to do other system 
calls and only the ones that get arguments (such as cstr) passed to them fail.
What is wrong with:

------------------------system_cd.c-------------------

#include <stdio.h>

system_cd (cstr)

	char *cstr;

	{
	char cmnd[50];
	sprintf(cmnd,"cd %s",cstr);
	printf(cmnd);
	system(cmnd);

	}
---------------------------------------------------------

it's declared in the pascal part like:

procedure system_cd (cstr: string); external c;

and called like:  {s is a string}

system_cd(substr(s, 4, length(trim(s))));

Simple calls like "system_pwd() { system("pwd") }" work perfectly.

follow up to : jasonf@cetemp.Corp.sun.com

Thanks,
Jason Freund, Sun Microsystems,  jasonf@cetemp.Corp.sun.com  <== summer address
Deprtmnt of Computer Science, Univ California, Davis. freund@sakura.ucdavis.edu
Quantum Link: JasonF5,  Compu$erve: 72007,244, 690 Erie Dr, Sunnyvale, CA 94087
-------------------------------------------------------------------------------
STOLEN QUOTES -- Please give the authors credit if you know who they are!    
"To understand recursion, you need to understand recursion."
"Wow!  Virtual memory!  Now I'm gonna build me a REALLY big ram disk!"
"My other computer is a SUN3/50."  "E. Pluribus UNIX"   -- authors unkown 
Technical Details
Message-ID: <141406@sun.Eng.Sun.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!sun-barr!newstop!sun!jasonf

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!sun-barr!newstop!sun!jasonf
From: jasonf@cetemp.Eng.Sun.COM (Jason Freund)
Newsgroups: sun.tech,comp.lang.pascal
Subject: Sun Pascal: Pascal calls C
Keywords: Pascal Sun C
Message-ID: <141406@sun.Eng.Sun.COM>
Date: 27 Aug 90 23:23:50 GMT
Sender: news@sun.Eng.Sun.COM
Followup-To: jasonf@cetemp.Corp.sun.com
Lines: 44