代码不工作(C++ 联合和结构)

Code is not working (C++ unions and structures)

无论我重新格式化多少次,我都会不断收到各种错误。最终结果将是一个程序,可以将针对电机的功能保存在 telescope 中并设置坐标。任何帮助解释我在这个设置中做错了什么的帮助将不胜感激。这是代码:

//IDENTIFY RECEIVER OF MESSAGE / TYPE OF MESSAGE / VIEW ALL TO 1 DEVICE / VIEW SPECIFIC MESSAGE

 #include "messaging.h"
 #include <string.h>
 #include <stdio.h>

using namespace std;

typedef struct MGR{
mess_types messagetype;
int DeviceID;
union E{
    //why arte these underlined? 
    char INST[STRSIZE];
    int codes[NBRCODES];
    float coords[NBRCOORDS];
} message;
};// info;


void messager(){
MGR my_data;
my_data.messagetype = INST;
my_data.DeviceID = TECH1;
strcpy(my_data.message.INST, "GO HOME");

my_data.messagetype = CODES;
my_data.DeviceID = MOTOR1;
for (int nbr = 0; nbr < NBRCODES; nbr++){
    my_data.message.codes[nbr] = nbr;
    print_message(my_data);
}
}
int print_message(MGR mydata){
MGR noot;
scanf("%s", &mydata);
switch (mydata.messagetype){
case INST:
    printf("Message to Device %d", noot.DeviceID);
    break;
case CODES:
    printf("The setup codes for device %d are: \n", noot.DeviceID);
    for (int code = 0; code < NBRCODES + OFFSET; code++){
        printf("%4d\t", noot.message);
    }
        break;
case COORDS:
    printf("The setup codes for device %d are: \n", noot.DeviceID);
    for (int code = 0; code < NBRCODES + OFFSET; code++){
        printf("%4d\t", noot.message);
    }
        break;
    }
    printf("%c", mydata.messagetype);
    return(0)
    }

    void Sendmessage(){
        printf("This program does not work... it is under construction...");
} 

以防万一:这是头文件

#include "sprint1.h"
#include <string.h>
#include <stdio.h>
#define STRSIZE 50
#define NBRCODES 200
#define NBRCOORDS 200
#define OFFSET 100
#define FACTOR 50
#define TECH1 123
#define MOTOR1 4556
void messager();
int print_message(MGR mydata);
void Sendmessage();
enum mess_types {INST, CODES, COORDS};

错误列表:https://drive.google.com/file/d/0B0CXbbHDOrweQVVvOVU1M0VRaEE/view?usp=sharing

我假设列出的 header 是 "messaging.h"

MGR 在代码定义之前在 header 中被引用。 也许将定义移动到第一个引用之前的 header。