Returning a String type from a function (SOLVED)

Started by Akumayo, Tue 20/06/2006 04:01:38

Previous topic - Next topic

Akumayo

Is it possible to return a String instead of an int from a function?

I've found no easy way of doing so far.  The best I've got is to break the String down so that each char is returned as an int, and then another function puts the String back together using the numbers supplied... but that's too complicated I think.
"Power is not a means - it is an end."

scotch

#1
Sure, just... return a String.

String example() {
Ã,  Ã,  Ã,  Ã,  String a = "Hi there!";
Ã,  Ã,  Ã,  Ã,  return a;
Ã,  Ã,  }



Edit: I just realised that might look odd if you're used to only seeing AGS functions declared as "function name(arguments)".Ã,  Functions are actually declared like in most C like languages: "returntype name(arguments)", but to make things more readable for newbies AGS has #defined "function" to "int" somewhere in a header. So "function name(arguments)" is identical to "int name(arguments)".

Akumayo

#2
Oh, I didn't know that at all!Ã,  I'll try it.Ã,  Thank you.

EDIT:

Works flawlessly.  Thank you again.
"Power is not a means - it is an end."

SMF spam blocked by CleanTalk