Thread: passing character array as pass by reference?

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    106

    passing character array as pass by reference?

    i need to pass an array as pass-by-reference, but the following code gives me an error:

    Code:
    int openfile(char& []);
    anyone know how to get around this? anything would be appreicated.
    thanks!

  2. #2
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    when you pass by reference, you only need...

    Code:
    int openfile(char&);
    hasafraggin shizigishin oppashigger...

  3. #3
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    Arrays are passed by reference (using a pointer) by default so I don't see why you'd need to explicitly use reference syntax. What you're trying to do with the above code is pass an array of references (illegal). I'm not sure if this syntax is correct as I've never needed to do it, but you could try -

    int openfile(char (&array)[50]);

    You'd need to specify the size of the array doing it like this, as references aren't as flexible as pointers.

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    106
    thanks, sorensen. ill try that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  3. A pointer to a character pointer array... can't pass
    By Lynux-Penguin in forum C Programming
    Replies: 9
    Last Post: 10-12-2003, 10:53 PM
  4. passing a character array through a function
    By volk in forum C++ Programming
    Replies: 4
    Last Post: 04-06-2003, 05:47 PM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM