Passing Structure by Reference

This is a discussion on Passing Structure by Reference within the C Programming forums, part of the General Programming Boards category; Ok. This is what I did to solve the problem. Change: Code: LOGIN_GetUsername(STRUCT_Users, STRUCT_Login, COUNT_Struct_Users); To: Code: LOGIN_GetUsername(STRUCT_Users, &STRUCT_Login, COUNT_Struct_Users); ...

  1. #16
    Registered User
    Join Date
    Mar 2012
    Posts
    26
    Ok. This is what I did to solve the problem.

    Change:

    Code:
    LOGIN_GetUsername(STRUCT_Users, STRUCT_Login, COUNT_Struct_Users);

    To:

    Code:
    LOGIN_GetUsername(STRUCT_Users, &STRUCT_Login, COUNT_Struct_Users); // Added an ampersand.
    Code:
     
    Which is correct, right? Just wanted to double-check since I might encounter another hidden error.

  2. #17
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,454
    Well, yes, that is correct, but of course fixing one bug does not necessarily mean that there are no bugs left. Pay attention to your compiler's warnings.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Passing structure by reference or pointer?
    By 7force in forum C Programming
    Replies: 8
    Last Post: 12-13-2010, 05:49 PM
  2. Passing structure by reference through 4 functions
    By nickdavid35 in forum C Programming
    Replies: 14
    Last Post: 04-30-2010, 09:39 AM
  3. Problem Passing Structure Reference To Function
    By soj0mq3 in forum C Programming
    Replies: 9
    Last Post: 04-24-2010, 10:27 AM
  4. Reference to a Structure
    By boschow in forum C Programming
    Replies: 3
    Last Post: 03-28-2008, 02:37 PM
  5. passing by address vs passing by reference
    By lambs4 in forum C++ Programming
    Replies: 16
    Last Post: 01-09-2003, 12:25 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21