4 Replies - 2602 Views - Last Post: 23 December 2008 - 09:32 AM Rate Topic: -----

#1 eric_carwardine  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 22-December 08

Significance of asterisk (*) in function statement

Post icon  Posted 22 December 2008 - 06:51 PM

G'day, folks :)

My first question ...

What's the significance of the asterisk (*) between 'long' and 'temp' in the following? I can't find an explanation in dozens of (perhaps incomplete) online function definition texts.

tc08_get_temp 
unsigned short tc08_get_temp (
long * temp,
unsigned short port,
unsigned short channel,
unsigned short filtered); 



Posted Image "Ewik"

Is This A Good Question/Topic? 0
  • +

Replies To: Significance of asterisk (*) in function statement

#2 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3089
  • View blog
  • Posts: 19,137
  • Joined: 14-September 07

Re: Significance of asterisk (*) in function statement

Posted 22 December 2008 - 06:54 PM

It means temp is a pointer to a long variable. You can assign the address of another long variable to temp and do things, etc...
Was This Post Helpful? 0
  • +
  • -

#3 eric_carwardine  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 22-December 08

Re: Significance of asterisk (*) in function statement

Posted 22 December 2008 - 07:47 PM

View PostKYA, on 22 Dec, 2008 - 05:54 PM, said:

It means temp is a pointer to a long variable. You can assign the address of another long variable to temp and do things, etc...


A most useful clue, KYA. Thankyou! :wink:

I wonder if the space between * and temp mislead me? I'd read about pointers, but in all the examples the * was contiguous with the pointer name, i.e. no space between * and name, would be written as *temp.

Eric
Was This Post Helpful? 0
  • +
  • -

#4 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3089
  • View blog
  • Posts: 19,137
  • Joined: 14-September 07

Re: Significance of asterisk (*) in function statement

Posted 22 December 2008 - 09:45 PM

Whitespace is irelevant to the actual code. The compiler sees:

long* temp;
long *temp;
long * temp;



All as the same thing. It's a matter of style.
Was This Post Helpful? 0
  • +
  • -

#5 eric_carwardine  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 22-December 08

Re: Significance of asterisk (*) in function statement

Posted 23 December 2008 - 09:32 AM

Attached File  FZ1X.TXT (14.58K)
Number of downloads: 50I think I can now state my objective :)

The hardware is an 8 channel Thermocouple Data Logger, from Pico Technology, http://www.picotech.com

Supplied with the logger is a set of nine driver routines, in C/C++ One of the routines is tc08_get_temp Of all the files supplied, only two ( tc0832.lib and tc0832.dll ) contain any reference to the driver routines, as ascertained by a plain-text search for strings beginning with 'tc08_'

The Pico logger is the modern replacement for another thermocouple unit that used Assembler-language drivers that I wrote using Microsoft Assembler (MASM). The mainline program, which does some formidable mathematics, was also written by me, using Microsoft Fortran.

My project now is to re-work the Fortran mainline (see attachment, FZ1X.TXT), with its INTERFACE statements and calls to subroutines, so that it now makes function calls to the C/C++ Pico driver routines contained in, presumably, tc0832.dll ( 32 for 32-bit installation ).

A frequent need will be to write Fortran statements to invoke, for example, the function tc08_get_temp, whose C/C++ definition was given in a previous post. And here I'm reminded of things such as passed-by-reference versus passed-by-value.

I'm indebted to any member who can provide tips and pointers in this quest.

Eric
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1