c programming casting struct values -
c programming casting struct values -
i trying cast int value in struct double. guessing screwing parenthesis somehow. wasn't able find useful in forum or in google.
i added more info.
struct start { int x; int y; double heuristic; }; struct shapes { int x [100]; int y [100]; double heuristic [100]; int has_visited [100]; int num_points; int *link; }; struct line { int x1 [100]; int y1 [100]; int x2 [100]; int y2 [100]; }; double addition(double x, double y) { homecoming x + y; } int main(int argc, char *argv[]) { int kk = 0; double x = 0; double y = 0; double z = 0; struct start start; struct end end; struct shapes shapes[100]; struct line edges; x = (double)start.x; y = (double)edges.x1[kk]; z = addition((double)start.x, (double)edges.x1[kk]) homecoming 0; }
i tried running code bit of changes here , there , works me, except had comment out "(double)edges.x1[kk]" x1 not there in of structures, plus think need utilize "shapes" instead of "edges", don't know if have defined "edges" in other part of code. below tried:
#include <stdio.h> #include <string.h> #include <math.h> struct start { int x; int y; double heuristic; }; struct shapes { int x [100]; int y [100]; double heuristic [100]; int has_visited [100]; int num_points; int *link; }; struct line { int x1 [100]; int y1 [100]; int x2 [100]; int y2 [100]; }; void main() { int kk = 0; double x = 0; double y = 0; double z = 0; struct start start; //struct end end; struct shapes shapes[100]; struct line edges; start.x = 123; (double)start.x; edges.x1[kk] = 143; (double)edges.x1[kk]; printf("%d\t%d\n",start.x,edges.x1[kk]); z = (sqrt(start.x+edges.x1[kk])); printf("%f",z); }
c struct
Comments
Post a Comment