Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
struct assignment in main()
#include <stdio.h>
struct complex_struct {
double x, y;
};
struct complex_struct z;
/*expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token*/
/* assignment struct must be in main() */
int main(int argc, char const *argv[]) {
z.x = 1.0;
z.y = 2.0;
printf("z=%f+%fi\n", z.x, z.y);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment