Hi all,
its me again.can i have a function that return a double array?
ubi_ct83 -3 Junior Poster
Recommended Answers
Jump to PostTake a look at http://www.daniweb.com/forums/thread5939.html
SUMMARY: Pass a pointer to the start as a parameter to the function, and then return this pointer when you're done.
EDIT: Mentioned link is belongs to C++ example but it is an answer of your question.
For example,
double …
Jump to PostI tried that and worked. Why don't you give it a try:
#include <stdio.h> #define M 5 float* return_array(int size); main() { int i; float *t; t=return_array(M); printf("the elements of t array are:\n"); for (i=0; i<M; i++) printf("%f ",t[i]); printf("\n"); system("pause"); } float* return_array(int size) { int …
Jump to PostTry this..Does it do your job:
#include <stdio.h> #define M 3 #define N 3 float** return_array(int rows,int columns); main() { int i,j; float **t; t=return_array(M,N); printf("the elements of t array are:\n"); for (i=0; i<M; i++) { for (j=0; j<N; j++) printf("%f ",t[i][j]); printf("\n"); } system("pause"); } float** …
Jump to Post> Try this..Does it do your job:
Well it might, if you included stdlib.h as well.Then you might be able to call malloc without having to resort to dangerous casting (it's REALLY dangerous without a prototype, and essentially useless with a prototype).
Why is it dangerous?
Well …
All 16 Replies
kvprajapati 1,826 Posting Genius Team Colleague
ubi_ct83 -3 Junior Poster
vanalex 0 Junior Poster in Training
ubi_ct83 -3 Junior Poster
vanalex 0 Junior Poster in Training
Salem 5,265 Posting Sage
vanalex 0 Junior Poster in Training
Salem 5,265 Posting Sage
ubi_ct83 -3 Junior Poster
Salem 5,265 Posting Sage
ubi_ct83 -3 Junior Poster
Salem 5,265 Posting Sage
ubi_ct83 -3 Junior Poster
Salem 5,265 Posting Sage
kvprajapati commented: Good point. Excellent advice. +15
ubi_ct83 -3 Junior Poster
kvprajapati 1,826 Posting Genius Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.