Thread: Random behaviour structs please explain

  1. #1
    Registered User
    Join Date
    Mar 2008

    Random behaviour structs please explain

    Hi I was working on my project file and I have to do work with structs. So I created a sample program that is small to see how to implement in my program.

    Below is the program:

    #include <stdio.h>
    typedef struct{
    	double x;
    	double y;
    data function(void);
    int main(void)
    	double a, b;
    	data table;
    	table = function();
    	printf("%lf   %lf", table.x, table.y);
    	return 0;
    data function(void)
    	data fTable;
    	fTable.x = 4;
    	fTable.y = 5;
    	return fTable;

    Can I make a struct = another struct if they are of the same type?
    the output is 3 doubles (3.90000000 3.444000 3.09000), even if I take the printf out of the program lol!

    Help please!

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    1. Of course.
    2. This is false. The output of the program you have written and posted here is "4.000000 5.000000". Are you sure you actually compiled the program and are running this program and not some other one?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Making a random array of integers
    By Vidak in forum C# Programming
    Replies: 2
    Last Post: 11-09-2007, 06:00 AM
  2. Random number + guessing game trouble
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-08-2007, 03:33 AM
  3. Replies: 1
    Last Post: 12-14-2002, 01:51 AM
  4. Random number generator
    By Caze in forum C++ Programming
    Replies: 6
    Last Post: 12-03-2002, 08:10 AM
  5. Random Problem?
    By dizz in forum C++ Programming
    Replies: 4
    Last Post: 11-20-2002, 05:00 PM