CrazyEngineers
  • C Programming: Can a structure return value?

    naina755

    Member

    Updated: Oct 17, 2024
    Views: 1.1K
    In c data type structure is present ,structure allow to use different data type like int,char in the same program,my question is ,is structure return any value ?if it return any value what is the reason,if structure not return any value than what is the reason behind this.please reply
    I am new member so i do not know any thing about crazy engineer.if i asked any thing wrong then please correct me.
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • gaurav.bhorkar

    MemberMay 9, 2010

    Re: c language

    Welcome to CE, naina.

    Can you clarify your question?

    In C a structure is a collection if different data types. That is, we can have int, char, float or another structure as its members.

    And a structure does not return a value, a function returns a value. You can return a structure variable from a function, like any other variable.
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberMay 9, 2010

    Structure doesn't return anything it basically meant for user defined data types
    Are you sure? This action cannot be undone.
    Cancel
  • sushant005

    MemberMay 9, 2010

    Structure cannot return value since it is a user defined data type.

    It contains the collection of heterogenous data type means different data type like int,char,float evan arays and other structures
    and its only a logical concept.
    Are you sure? This action cannot be undone.
    Cancel
  • elizas

    MemberJun 14, 2010

    I declared a variable as “int” data type for a PatientId. It worked fine in local, but when that code went to LIVE, the application gave exception because in LIVE PatientId is too long to accommodate in int data type.

    So before declaring any variable we need to consider all the situations, application scope, environment .Even one code may be working fine today, after 1/ 10/20 days/months/years it will fail due to just due to data type declaration mistake.

    Think more; write less is the policy for better programming.

    My Experience No 2:

    I declared a variable as int data type which was a placeholder for a result status (meaning, based on the result status that variable varies from 0/1/2/3. It can contain only these four values).

    “int” data type is 4 byte integer in C#. But I can declare this variable as “sbyte” which represents a 1 byte integer. Since that variable contains only 1 or 2 or 3 or 4, declaring the variable as “int” is wastage of memory space.

    Before declaring any variable we need to just think of the memory space needed for that variable, our requirement, any other good alternative for this variable.

    #-Link-Snipped-#
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register