return-value

I am trying to return a Character Array but i'm only getting the first letter!

I'm working on a small little thing here for school. After hours of researching, and a ton of errors and logic reworking I've almost completed my little program here. I'm trying to take user input, store it into the string, get a character array from the string ( dont ask why, I just have to put this into a character array ), then get t...

Using python ctypes to get buffer of floats from shared library into python string

I'm trying to use python ctypes to use these two C functions from a shared library: bool decompress_rgb(unsigned char *data, long dataLen, int scale) float* getRgbBuffer() The first function is working fine. I can tell by putting some debug code in the shared library and checking the input. The problem is getting the data out. The RG...

How to call an external program in python and retrieve the output and return code?

Hi, How can I call an external program with a python script and retrieve the output and return code? ...

Should Java method arguments be used to return multiple values ?

Since arguments sent to a method in Java point to the original data structures in the caller method, did its designers intend for them to used for returning multiple values, as is the norm in other languages like C ? Or is this a hazardous misuse of Java's general property that variables are pointers ? ...

How do I use LINQ on a store procedure with a Select Statment?

Hi there, How do I use LINQ on a store procedure with a Select Statment? I know how can I use store procedure to execute some procedure for me, however, if I want to return some data from a store procedure? How do I do that? Regards ...

Return code when OS kills your process

Hello, I've wanted to test if with multiply processes I'm able to use more than 4GB of ram on 32bit O.S (mine: Ubuntu with 1GB ram). So I've written a small program that mallocs slightly less then 1GB, and do some action on that array, and ran 5 instances of this program vie forks. The thing is, that I suspect that O.S killed 4 of them...

How to elegantly ignore some return values of a MATLAB function?

I was wondering if it was possible to get the nth return value from a function without having to create dummy variables for all n-1 return values before it. Let's say I have the following function in MATLAB: function [a,b,c,d] = func() a = 1; b = 2; c = 3; d = 4; Now suppose that I'm only interested in the third return value. This ca...

How to deal with list return values in ANTLR

What is the correct way to solve this problem in ANTLR: I have a simple grammar rule, say for a list with an arbitrary number of elements. list : '[]' | '[' value (COMMA value)* ']' If I wanted to assign a return value for list, and have that value be the actual list of returned values from the production, what is the proper way to ...

Exception, Return, Serializable,

How does (throw Exception) and (return value) is implemented in a Language such as Java or C#? I want to know the mechanism how its support is included in a Language and not just the usage of try { .... } catch (Exception) {} ? We know when we call a function i.e. public void doSomething() { .... .... return; } Then on the call ...

C#: Returning 'this' for method nesting?

I have a class that I have to call one or two methods a lot of times after each other. The methods currently return void. I was thinking, would it be better to have it return this, so that the methods could be nested? or is that considerd very very very bad? or if bad, would it be better if it returned a new object of the same type? Or w...

Which are the implications of return a value as constant, reference and constant reference in C++ ?

Hello. I'm learning C++ and I'm still confused about this. What are the implications of return a value as constant, reference and constant reference in C++ ? For example: const int exampleOne(); int& exampleTwo(); const int& exampleThree(); ...

String or StringBuilder return values?

If I am building a string using a StringBuilder object in a method, would it make sense to: Return the StringBuilder object, and let the calling code call ToString()? return sb; OR Return the string by calling ToString() myself. return sb.ToString(); I guess it make a difference if we're returning small, or large strings. What wo...

Why do most programming languages only give one answer to square root of 4?

Most programming languages give 2 as the answer to square root of 4. However, there are two answers: 2 and -2. Is there any particular reason, historical or otherwise, why only one answer is usually given? ...

object returned after an exception?

int somefunction(bool a) { try { if(a) throw Error("msg"); return 2; } catch (Error const & error) { //do i need to return anything here?? //return -1; } } ...

How can I return an array?

Is there any way to return an array from a function? More specifically, I've created this function: char bin[8]; for(int i = 7; i >= 0; i--) { int ascii='a'; if(2^i-ascii >= 0) { bin[i]='1'; ascii=2^i-ascii; } else { bin[i]='0'; } } and I need a way to return bin[]. ...

Why does the return keyword cause problems in my 'if block'?

The following code works fine: person = {:a=>:A, :b=>:B, :c=>:C} berson = {:a=>:A1, :b=>:B1, :c=>:C1} kerson = person.merge(berson) do | key, oldv, newv | if key == :a oldv elsif key == :b newv else key end end puts kerson.inspect but if I add the return keyword inside the "if block", I get an error: person = {:a=>:A, :b=>:B,...

Should I always give a return value to my function?

I write JavaScript code and I try to use its functional language nature. In other functional languages (or even in Ruby), if I don't explicitly set the return value of a function, it will return the value of the last evaluated expression. JavaScript does not follow this pattern. (To be precise, JavaScript always returns a value as well....

Changing a return type depending on the calling method

Basically what I want, istwo public methods with slightly different return values to call the same method to do whatever work is needed. They both return the return value of the private method, however the private method will know how to return the correct value depending on the public method that called it. Example methods: public Map...

Is it possible to exit gracefully in a constructor?

Is it possible to exit gracefully out of a constructor in php? Something to the effect of class Foo { function __construct() { $active = false; if(!$active) { return false; } } } I'm trying to accomplish this because I want to check to see if any of the methods in the class should run based on a configuration ...

How to run a external Program and get the return-code in a Firefox-Addon

Hy, I'm trying to launch a external process from a mozilla firefox addon (so only js-code allowed). This is easly possible using NSIProcess, but I need the return-code of the executed program. As the NSIProcess doesnt offer a possibility to get the return-code, I'm searching for a alternative possibility. Im trying to avoid to write my ...