C++/help!

Advertisement


Question
i have created:
struct gateType {
      char type[5];
      int input1PinOrder;
      int input2PinOrder;
      int outputPinOrder;
      };
      
struct gateType myGates[8][3];

but in the main program when i write:
myGates[j][i].type="and";
the compiler says: incompatible types in assignment! what should i do??

Answer
Do it like this:

#include <string.h>

struct gateType {
   char type[5];
   int input1PinOrder;
   int input2PinOrder;
   int outputPinOrder;
};

gateType myGates[8,3];

main(){
 i = 2;
 j = 1;
 strcpy(myGates[j][i].type, "and");
}

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Sam

Expertise

You may ask me about simple to complicated C/C++ programming methods/style and most like questions about network programming in C++.

Experience

I'm a professional programer in C++ and network/internet programming.

©2016 About.com. All rights reserved.