Thread: Miracle C - Strutures

  1. #1
    Registered User
    Join Date
    Sep 2002

    Miracle C - Strutures

    Does anyone know how to pass structures to and from a funtion in miracle c? this is the code for turbo C++ i think but it not work because of the diffrences in compiler. any ideas?


    #include <stdio.h>

    struct exam {
    int mark;
    float av;

    struct exam grade(void);

    void main()
    printf("%d, %f", result.mark, result.av);

    struct exam grade(void)
    struct exam temp;

    temp.mark = 100;
    temp.av = 123.23;

    return temp;

    Shizzle Ma 'C' Whizzle's

  2. #2
    Join Date
    Aug 2001
    Groningen (NL)
    Miracle C is a C compiler, Turbo C++ is a C++ compiler. This is an important difference.

    Function main() should be of type int and return an int-value.

    What does not work on your code or what errors does your compiler give? I've compiled it with GCC and have no problems.

    About passing a structure:

    /* When structure is only used for its info, pass it by value */
    void function (struct exam result)
        printf("%d, %f", result.mark, result.av);
    /* When adaptation of structure is necessary use pointer to struct */
    void function (struct exam *result)
        result->mark = 1;
        result->av = 1.0;
    Last edited by Shiro; 01-19-2003 at 06:16 AM.

  3. #3
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Tags on this board are encased in '[', not '<'
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help With Miracle C
    By thirdchild in forum C Programming
    Replies: 7
    Last Post: 02-04-2008, 12:05 PM
  2. Support for Miracle C
    By AQWst in forum C Programming
    Replies: 5
    Last Post: 12-11-2004, 10:17 AM
  3. A Miracle has occurred in the realm of Hot Dogs
    By DavidP in forum A Brief History of
    Replies: 11
    Last Post: 05-08-2004, 03:18 PM
  4. miracle c?
    By wraith8 in forum C Programming
    Replies: 2
    Last Post: 08-06-2003, 09:27 PM
  5. Miracle C [I Need Help With Coloured Text]
    By paulroseby in forum C Programming
    Replies: 5
    Last Post: 09-29-2002, 11:50 AM