|
|
|
|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
Function to return an array of integer
Hi all,
I am trying to create a function that return an array of integer based on the char parameter pass into the function. I.e. func_a(char * str) { example str is equal to "1,2,3,4" return an array of integers of 1,2,3,4 } Please advise regards dwgi32 |
| Sponsored Links | ||
|
|
|
|||
|
The C language does not let you return an array unless you either (a) just return a pointer to the type of whatever the array is, and you have to allocate that array, eg you return an "int *". (b) use a typedef to define the array, and then return that.. Code:
typedef int array_int3[4];
array_int3 func(...)
{
array_int3 ret={1,2,3,4};
return ret;
} |
|
|||
|
Hi Potter,
Tks a lot. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| need to return value from function | darshakraut | Shell Programming and Scripting | 5 | 05-14-2008 09:13 AM |
| function return array | dophine | Shell Programming and Scripting | 6 | 05-06-2008 01:16 PM |
| Return an array of strings from user defined function in awk | user_prady | Shell Programming and Scripting | 2 | 12-04-2007 12:03 AM |
| To return the elements of array | Sudhakar333 | Shell Programming and Scripting | 5 | 08-06-2007 03:20 PM |
| C function to test string or integer | qqq | Programming | 3 | 03-10-2005 01:55 AM |