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
    24,870
    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.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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, 06:49 PM
  2. Passing structure by reference through 4 functions
    By nickdavid35 in forum C Programming
    Replies: 14
    Last Post: 04-30-2010, 10:39 AM
  3. Problem Passing Structure Reference To Function
    By soj0mq3 in forum C Programming
    Replies: 9
    Last Post: 04-24-2010, 11:27 AM
  4. Reference to a Structure
    By boschow in forum C Programming
    Replies: 3
    Last Post: 03-28-2008, 03:37 PM
  5. passing by address vs passing by reference
    By lambs4 in forum C++ Programming
    Replies: 16
    Last Post: 01-09-2003, 01: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