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:
the compiler says: incompatible types in assignment! what should i do??

Hello maki, thank you for the question.

If you want to be able to directly assign a value to a string, the std::string class has the = operator overloaded for that purpose. Otherwise, it is illegal. The wasy to do this is with a call to strcpy to copy the string into the array:

strcpy(myGates[j][i].type, "and", sizeof(char)*5));

This copies over 5 bytes from the source, to the destination.

strcpy is located in the file string.h

I hope this information was helpful.

- Eddie


All Answers

Answers by Expert:

Ask Experts




I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.


I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 About.com. All rights reserved.