Thread: const array float

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    32

    const array float

    I was wondering how I would go about to pass a constant float array into a function in the same way you can pass const char arrays.

    eg.
    Code:
    parse_file("load.txt");
    for the moment I write it like this
    Code:
    temp[]={0.3,0.3,0.3,1.0};
    arrayFunc(temp);
    Is there a way to define an array in the function arguments just like for strings? What's the syntax?

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    Code:
    void arrayFunc(const float array[]);

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    32
    Thanks for your speedy answer!

    That's not what I meant though. I'm asking about how to pass the array to the function. Not how to define the function.

    /Hubas

  4. #4
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    You can't do it inline without using the processor to do some trick.

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    32
    ok...thanks...

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > I'm asking about how to pass the array to the function. Not how to define the function.
    You already know how - that's what you pasted in your original post.
    Add to that Speedy5's answer, and you're there.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Promblem with code
    By watchdogger in forum C Programming
    Replies: 18
    Last Post: 01-31-2009, 06:36 PM
  2. Could somebody please help me with this C program
    By brett73 in forum C Programming
    Replies: 6
    Last Post: 11-25-2004, 02:19 AM
  3. Problem with Template Function and overloaded equality operator
    By silk.odyssey in forum C++ Programming
    Replies: 7
    Last Post: 06-08-2004, 04:30 AM
  4. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM
  5. Why does it work in Visual Studio and Not Borland
    By MonteMan in forum C++ Programming
    Replies: 14
    Last Post: 10-20-2002, 09:36 PM