answersLogoWhite

0


Best Answer

To fulfill the purpose I don't use return but use a different method. pass by references:

#include<stdio.h>

void myFunc(int n[]){

int i;

for(i = 0; i<10; i++)

n[i] = i;

}

int main(void){

int a[10];

int i;

myFunc(a);

for(i=0; i<10; i++){

printf("%d\n",a[i]);

}

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

Nothing special, but never return local (automatic) variables.

bad example:

char *fun (void) {

char local [32];

return local;

}

good example:

char *fun (void) {

char *local= malloc (32);

return local;

}

/* warn the caller that they have to free the memory */

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

The main function returns its result at the end of the function body. It is bad practice to sprinkle "return" statements within the function body, and other methods of exiting a C program (e.g. use of longjmp and exit) also make it harder to debug.

An application A's main function's result is returned to the caller, which resides in process B. B is the process which launched application A. For example, if A was a simple console tool, B could be the console window (cmd.exe in a Windows operating system). B could also be a suitable file explorer, or pretty much any other type of process.

The calling process B typically examines A's return code. By convention, a return code of 0 (zero) indicates success without errors (zero errors). A non-zero return code typically indicates completion with at least one error, and the value of the return value can give clues into the nature of the error. The non-zero result codes (sometimes also called error levels) are not generally standardized though.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

In C you would simply return a char pointer to the start of the array. In C++ you can still do that but it's better to return a vector instead.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Where does the main function return the value in C programming language?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How does the compiler differentiate the statement and function in C programming?

statement should not return a value but function returns a value


What is a function in C programming language?

A function is a subroutine that can be called from several places (re-usable code). Functions can accept arguments (or parameters) so that they can be more generalised and can also return a value to the caller.


Why you use void res in c programming?

since, the word 'void' in C programming language means that it does not return any value to the user or calling function....this is usually used to specify a type of function...... for this reason w use 'void'in c program..


How do you convert numeric value into alpha value in c plus plus programming language?

use the _itoa function


What is accumulator function in c language?

Normally the return value from the function is through the information from the accumulator.


How many types of function in C?

Well, it depends on what you mean by the type of a function. There are user defined functions and library functions.


When a function does not return a value what kind of function is it called?

In most computer languages, a procedure that returns a value is called a function and a procedure that does not return a value is called a subroutine or subprogram. Usually the languages treat the passing of arguments/parameters differently between functions and subroutines. The C language does not distinguish between them. A subroutine that does not return a value is define as a "void" function indicating that no return value is used or available.


Difference in using a method that return value and method that does not return value in object orinted programming?

A method that return a value should have a return statement. The method signature should indicate the type of return value. While in the case of a method that does not return a value should not have a return statement and in the signature, the return type is void. When using a method that doesn't return a value, a programmer can not get a value from that function, but instead, it can only change variable values and run other methods.


What is return in programming?

The return statement is used in functions to return control to the caller. If the function is declared non-void, the return statement also allows the programmer to return a value to the caller.


How do you use return?

In C/C++ programming and most other procedural languages, you use a return statement to return control to the calling function. In the case of the global main function, a returnstatement terminates the program, releasing all memory used by the program and returning control to the execution environment.Functions that return void do not return a value and therefore do not require a return statement, unless the function needs to return early (before falling off the end of the function). Functions that return values must use a returnstatement to return the appropriate value to the caller.In C++ (but not in C), the global main function does not require a return statement unless returning early. When omitted, the global main function implicitly returns the value 0 (to the execution environment) when execution falls off the end of the function. To return any other value, a return statement is required.


How do you return a value in a PHP function?

Below is a simple example of how you could return a value in a PHP function. &lt;?php function returnme($value) { return $value; } echo returnme('hello'); // outputs: hello ?&gt;


Is function always return a value?

no, every function can not return a value. for example void name() { cout&lt;&lt;"Hello world"; } this function does not return any value due to the key word void that tells the compiler that the function does not returns a value.