Global Array with size for input

A

Aleramo

Hallo, i have to do a program with gsl library. I have to declare two
global array cos i can't pass them to gsl functions. The problem is the
size is an input from program. What can i do? I want to try it: .......
/* Declaration global variables */ int elementi ; gsl_vector_complex
*s_v= gsl_vector_complex_alloc (elementi) ; double esponenti [elementi]
; ....... int main () { ...... scanf ("%d", &elementi) ;
/* inizializzation esponenti */ /* gsl function with the
inizialization of s_v inside a for () */ ...... return 0 ; }
What can i do? By Aleramo.
 
V

Vladimir S. Oka

Aleramo said:
Hallo, i have to do a program with gsl library. I have to declare two
global array cos i can't pass them to gsl functions. The problem is
the size is an input from program. What can i do? I want to try it:
....... /* Declaration global variables */ int elementi ;
gsl_vector_complex *s_v= gsl_vector_complex_alloc (elementi) ; double
esponenti [elementi]
; ....... int main () { ...... scanf ("%d", &elementi) ;
/* inizializzation esponenti */ /* gsl function with the
inizialization of s_v inside a for () */ ...... return 0 ; }
What can i do? By Aleramo.

Before anyone will even try to read your code, please format it and
indent properly. Please also note that `......` is not a valid C syntax
construct. Ideal is a properly indented complete example that can be
cut, pasted, and compiled (ideally with no errors).

Also, `gsl` library (whatever that is) is not part of Standard C and
hence not topical here. This means that nobody here will even try to
figure out whether you problem lies in that library, let alone what it
might be. Try to make your example and question independent of the
`gsl` library.

As a hint, you can try dynamically allocating the memory you require.

Cheers

Vladimir
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,174
Messages
2,570,940
Members
47,484
Latest member
JackRichard

Latest Threads

Top