Liste des Groupes | Revenir à co vms |
On 8/21/2024 8:26 AM, chrisq wrote:Problem is that of you return a pointer, that suggests that theOn 8/21/24 02:25, Lawrence D'Oliveiro wrote:In C one should definitely return a pointer to struct and notOn Tue, 20 Aug 2024 09:47:36 -0400, Arne Vajhøj wrote:>Few languages support multiple return values.>
Even in C and Fortran, a function can return a struct.
Better to declare the struct externally, then pass a pointer
to it. Much tidier.
a struct.
It looks like VSI Fortran cannot return a structure as function
result, but VSI Pascal can return a record as function result.
And it is returned as a pointer argument under the hood.
$ type s.pas
module s;
type
iiituple = record
a : integer;
b : integer;
c : integer;
end;
[global]
function get : iiituple;
var
res : iiituple;
begin
res.a := 123;
res.b := 456;
res.c := 789;
get := res;
end;
end.
$ pas s
$ type m.c
#include <stdio.h>
struct iiituple
{
int a;
int b;
int c;
};
void get(struct iiituple *res);
int main()
{
struct iiituple res;
get(&res);
printf("%d %d %d\n", res.a, res.b, res.c);
return 0;
}
$ cc m
$ link m + s
$ run m
123 456 789
Arne
Les messages affichés proviennent d'usenet.