473,387 Members | 1,291 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Casting ? Help urgently needed!

I'm getting tired of the following error message.
Compiler Error message : Error: Need explicit cast to convert
from: float
to: float *

I am trying to use a routine from the Numerical Recipes library called
amebsa.c. The routine requires several parameters of the following
form. *iter, **p, *yb.... . How does one initialize these variables?
If I declare them as pointer (in this case, *yb and *iter) the
compiler still tells me that it needs an explicit cast to covert the
variables from: float to: float *.
Surprisingly the compiler seems to accept the variable defined as **p,
which I initialized that way (float **P;)

additionally I don't know how to use void functions!! Where is the
result of the routine being stored?

Since this the basis of my thesis, I would really be grateful for any
ideas or suggestions!!!
Thanks folks
Nov 14 '05 #1
5 1892
to*********@hotmail.com (el prinCipante) wrote in
news:e8**************************@posting.google.c om:
I am trying to use a routine from the Numerical Recipes library called
amebsa.c. The routine requires several parameters of the following
form. *iter, **p, *yb.... . How does one initialize these variables?
If I declare them as pointer (in this case, *yb and *iter) the
compiler still tells me that it needs an explicit cast to covert the
variables from: float to: float *.
Surprisingly the compiler seems to accept the variable defined as **p,
which I initialized that way (float **P;)
If you have a pointer to float:

float *pFloatVar;

Then you can call a function that expects a pointer to a pointer to
float:

someFunction(&pFloatVar);
additionally I don't know how to use void functions!! Where is the
result of the routine being stored?


Void functions return nothing. The function will point your pointer to the
answer (the return value if you will).

--
- Mark ->
--
Nov 14 '05 #2
el prinCipante wrote:
I'm getting tired of the following error message.
Compiler Error message : Error: Need explicit cast to convert
from: float
to: float *

I am trying to use a routine from the Numerical Recipes library called
amebsa.c. The routine requires several parameters of the following
form. *iter, **p, *yb.... . How does one initialize these variables?
If I declare them as pointer (in this case, *yb and *iter) the
compiler still tells me that it needs an explicit cast to covert the
variables from: float to: float *.
Surprisingly the compiler seems to accept the variable defined as **p,
which I initialized that way (float **P;)

additionally I don't know how to use void functions!! Where is the
result of the routine being stored?

Since this the basis of my thesis, I would really be grateful for any
ideas or suggestions!!!
Thanks folks


I believe you need to review the pointers topic in your
favorite C language reference.

The term "float *" refers to a pointer to a variable of type
float, such as:
float my_float_variable;
float * pointer_to_float;
/* ... */
pointer_to_float = &my_float_variable;
The line above makes the pointer point to "my_float_variable".

The term "float * *" refers to a pointer that points to
a pointer to float, also known as double indirection. This
type is commonly used when a function wants to change the
contents of a pointer (i.e. make the pointer point to
another variable).

void initialize_a_pointer(float * * ptr_ptr_float)
{
*ptr_ptr_float /* reference the pointer */
= malloc(sizeof float); // get a pointer from
// dynamic memory
return;
}

int main(void)
{
float * ptr_to_float; /* Declare a pointer. */
/* The content is not set. */

initialize_a_pointer(&ptr_to_float);
/* The above call will allocate a float variable
* from dynamic memory and set "ptr_to_float" to
* point to it.
*/

*ptr_to_float = 3.14159264;
printf("float value is %f\n", *ptr_to_float);
return;
}

Notes:
1. The result from malloc() should be checked for NULL,
which indicates that the allocation failed.
2. If the pointer is null, then the assignment of
3.14159264 will fail (or cause undefined behavior).

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Nov 14 '05 #3
el prinCipante wrote:
I'm getting tired of the following error message.
Compiler Error message : Error: Need explicit cast to convert
from: float
to: float *

Since this the basis of my thesis[...]


If you do not understand pointers at this stage, you are better off
buying a C/C++ book. Your questions just show a deep lack of
understanding of poitners, so you need to fully understand the difference
between "float" and "float *", and you need to know why void functions
can still return results through pointers.

If you are pressed for time, then I would run out and get a mathematical
program (spending $1000 for Methematica is much cheaper than the time you
will spend mastering C in order to run some routines).

Or you could hire a computer science student to do it right. You do not
want to get a result, and then realize (or not realize) that the result
you gave was actually a memory address and not the actual result!

--
gabriel
Nov 14 '05 #4
Hello Gabriel,

Contact me off list from my web site
http://www.megaone.com/expert2003/consultant.htm
I shall work your assignment out instead of you for a fee.

Mr. Fairman
gabriel <no@no--spam.com> wrote in message news:<f3**************************@msgid.meganewss ervers.com>...
el prinCipante wrote:
I'm getting tired of the following error message.
Compiler Error message : Error: Need explicit cast to convert
from: float
to: float *

Since this the basis of my thesis[...]


If you do not understand pointers at this stage, you are better off
buying a C/C++ book. Your questions just show a deep lack of
understanding of poitners, so you need to fully understand the difference
between "float" and "float *", and you need to know why void functions
can still return results through pointers.

If you are pressed for time, then I would run out and get a mathematical
program (spending $1000 for Methematica is much cheaper than the time you
will spend mastering C in order to run some routines).

Or you could hire a computer science student to do it right. You do not
want to get a result, and then realize (or not realize) that the result
you gave was actually a memory address and not the actual result!

Nov 14 '05 #5
Groovy hepcat el prinCipante was jivin' on 23 Jan 2004 08:08:04 -0800
in comp.lang.c.
Casting ? Help urgently needed!'s a cool scene! Dig it!
I'm getting tired of the following error message.
Compiler Error message : Error: Need explicit cast to convert
from: float
to: float *
Then stop trying to convert a float to a pointer. What on Earth are
you doing that for? It's a rather silly thing to do, not to mention
illegal.
I am trying to use a routine from the Numerical Recipes library called
amebsa.c. The routine requires several parameters of the following
For those of us who haven't read that book and consequently don't
know the file or function, please state its purpose, prototype and
definition (code).
form. *iter, **p, *yb.... . How does one initialize these variables?
Mu. Without knowing the slightest thing about the function, how can
we say what to pass to it?
If I declare them as pointer (in this case, *yb and *iter) the
compiler still tells me that it needs an explicit cast to covert the
variables from: float to: float *.

Surprisingly the compiler seems to accept the variable defined as **p,
which I initialized that way (float **P;)
And, to what does this pointer point?
additionally I don't know how to use void functions!! Where is the
What do you mean? void functions are functions that simply return
void (ie., no value). You simply call such a function, and don't use
the (non-existant) return value in an expression. What's the problem?
What don't you understand?
result of the routine being stored?
What result? A void function doesn't have a result (return value).
Since this the basis of my thesis, I would really be grateful for any
ideas or suggestions!!!


You're writing a thesis without knowing the first thing about the
subject thereof? Good luck! You'll need it.

--

Dig the even newer still, yet more improved, sig!

http://alphalink.com.au/~phaywood/
"Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
I know it's not "technically correct" English; but since when was rock & roll "technically correct"?
Nov 14 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kamliesh Nadar | last post by:
Hi I am developing a software using VB.NET I am facing following problems - 1. Though I have placed the NotifyIcon control on the window service application, after starting the service I am...
4
by: Andy Franks | last post by:
Hi All, This is driving me nuts, especially since I have this working for my main application with no problem. I suspect it might be due to Namespace conflicts, but I'm not positive. Any help...
1
by: Remco | last post by:
Hi, Let me try to simply explain my questions. I've created a portal site with different types of users, e.g. Portal Administrators and Normal Users. One base class SessionUser (has a enum...
1
by: Rob Reagan | last post by:
Can someone explain to me why I must explicitly cast UP a class heiarchy when using option explicit? For instance, I have a typed dataset (which is derived from the DataSet class) and I'm passing...
9
by: Brian | last post by:
Hello! What is the proper syntax for casting? For example, how do I change an Integer in to a String if the variable is called Joe1 and has 20 assigned to it. Thanks, Brian
3
by: Beta What | last post by:
Hello, I have a question about casting a function pointer. Say I want to make a generic module (say some ADT implementation) that requires a function pointer from the 'actual/other modules'...
1
by: pathakrajeev | last post by:
Hi I needed help urgently. Suppose I have file name like test12wehow.asp test11234r5wesow.asp,upppwenow.asp. one thing is common in all the files are "we". I want to read the file as...
1
by: janakivenk | last post by:
Hello, I am running Oracle 10g R2 in our office. I created the following procedure. It is suppose to access an xml file ( family.xml). The procedure is compiled and when I try to run it, i get the...
1
by: Robert Wells | last post by:
Gentlemen, We are looking for two IBM documents that are needed urgently for a project. They are titled "4680 Store Systems Serial I/O Channel Attachment Information" and "Serial I/O Product...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.