Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Can some one te...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 15 Topic 24905 of 27671
Post > Topic >>

Can some one tell me what is wrong with this program ?

by broli <Broli00@[EMAIL PROTECTED] > Mar 12, 2008 at 08:08 AM

#include<stdio.h>
#include<stdlib.h>


struct point

{

  double x, y, z;

};

typedef struct point point;



struct triangle

{

  point x,y, z;

};

typedef struct triangle triangle;



int main(void)

{

  triangle *T;

  T =3D malloc(sizeof(triangle));
  printf("Enter the vertices of the triangle\n");
  printf("First vertex:\n");
  scanf("%lf %lf %lf", &(T->x.x), &(T->x.y), &(T->x.z));
  printf("Second vertex:\n");
  scanf("%lf %lf %lf", &(T->y.x), &(T->y.y), &(T->y.z));
  printf("Third vertex:\n");
  scanf("%lf %lf %lf", &(T->z.x), &(T->z.y), &(T->z.z));
  printf("Vertex 1: %lf\t%lf\t%lf\n", T->x.x, T->x.y, T->x.z);
  printf("Vertex 2: %lf\t%lf\t%lf\n", T->y.x, T->y.y, T->y.z);
  printf("Vertex 3: %lf\t%lf\t%lf\n", T->z.x, T->z.y, T->z.z);

  return 0;

}

I'm getting some garbage values in the output.

=1A
 




 15 Posts in Topic:
Can some one tell me what is wrong with this program ?
broli <Broli00@[EMAIL   2008-03-12 08:08:17 
Re: Can some one tell me what is wrong with this program ?
Richard Heathfield <rj  2008-03-12 15:21:50 
Re: Can some one tell me what is wrong with this program ?
broli <Broli00@[EMAIL   2008-03-12 09:00:59 
Re: Can some one tell me what is wrong with this program ?
broli <Broli00@[EMAIL   2008-03-12 09:09:22 
Re: Can some one tell me what is wrong with this program ?
rlb@[EMAIL PROTECTED] (R  2008-03-12 16:16:36 
Re: Can some one tell me what is wrong with this program ?
Nick Keighley <nick_ke  2008-03-12 09:15:14 
Re: Can some one tell me what is wrong with this program ?
broli <Broli00@[EMAIL   2008-03-12 09:20:24 
Re: Can some one tell me what is wrong with this program ?
rlb@[EMAIL PROTECTED] (R  2008-03-12 16:28:10 
Re: Can some one tell me what is wrong with this program ?
Keith Thompson <kst-u@  2008-03-12 09:55:22 
Re: Can some one tell me what is wrong with this program ?
Kenneth Brody <kenbrod  2008-03-12 15:28:35 
Re: Can some one tell me what is wrong with this program ?
broli <Broli00@[EMAIL   2008-03-12 12:35:26 
Re: Can some one tell me what is wrong with this program ?
santosh <santosh.k83@[  2008-03-13 01:18:29 
Re: Can some one tell me what is wrong with this program ?
broli <Broli00@[EMAIL   2008-03-12 12:39:54 
Re: Can some one tell me what is wrong with this program ?
Keith Thompson <kst-u@  2008-03-12 23:01:48 
Re: Can some one tell me what is wrong with this program ?
Morris Dovey <mrdovey@  2008-03-12 18:02:07 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 8:27:35 CDT 2008.