title: String problems in C: operands of unequal types, char[255] and char*
body: <p>When i try to compile my code i get the following errors:</p>
  
  <pre><code>error #2168: Operands of '=' have incompatible types 'char [255]' and 'char *'.
  error #2088: Lvalue required.
  </code></pre>
  
  <p>i get these errors for the same line (ie 1044), and on a multiple of lines, so i figure by fixing one i can fix the others, so let me copy you the codes. You can skip and only read lines where comments start with ** just to make it easier :) and ending with &lt;--
  I hope the in code comments serve you well:
  first let me start by defining the type PRINTOPT</p>
  
  <pre><code>typedef struct {
      //UsePl signifies if the user would like to see the graphs without having to export data
      //Thanks to PlPlot library. 
      int usePl;
  
      //Feel free to customize and add to this struct
      //for any simulation program you create.
      //---- Note2self: probably change the graph bool to an array,
      //as later you will have to print around 20 graphs or so
  
      int thetaGraph;     //Plot Theta VS Time
      int omegaGraph;     //Plot Omega VS Time
  
  
      char filename[255]; //**I have declared it to be a 255 char. &lt;============
      int matlab;     //0 no, not 0 yes;
  } PRINTOPT;
  </code></pre>
  
  <p>function which raises the error
      int ReadPrintOpt(PRINTOPT *opt) {
          int input;</p>
  
  <pre><code>    int usePl;
      int thetaGraph;     
      int omegaGraph;
  
      //**The result behind this def, i would like the user to input a filename
      //To save his data in,  &lt;========================================================
      char filename[255] = "Osc Motion and Chaos- Results"; //I have declared filename as char [255]
  
      int matlab;
      printf("\n----Print Options----\n");
      printf("\nMENU (choose one of the following commands)\n");
      printf("\n\t 1 - Display Graphs after Simulation\t\t\tCurrent Val\t\"%d\"",opt-&gt;usePl);
      printf("\n\t 2 - Enable Theta vs Time Graph\t\tCurrent Val\t\"%d\"",opt-&gt;thetaGraph);
      printf("\n\t 3 - Enable Omega vs Time Graph\t\tCurrent Val\t\"%d\"",opt-&gt;omegaGraph);
      printf("\n\t 4 - Save Data in Matlab Format\t\tCurrent Val\t%d",opt-&gt;matlab);
      printf("\n\t 5 - Filename for exported files\t\tCurrent Val\t%s",opt-&gt;filename);
      printf("\n\n\t 0 - &lt;DONE&gt;\n&gt;&gt;");
      scanf("%d",&amp;input);
  
      switch(input) {
          case 0: 
              return 0;
          case 5:
              printf("Enter Filename: ");     
              fgets(filename, 255, stdin);    //**i've been told to use this, saw it on another question
              opt-&gt;filename = filename;   //**In this part, opt is of type PRINTOPT
              //I have been told that the name of an array, is actually 
              //a pointer to the first element, so why does this part 
              //give me this error -- Operands of '=' have incompatible types 'char[255] and [char*]
              //although i've declared both as char[255]; 
              break;
          case 4:
              printf("Enable Matlab (0 no, else yes): ");
              scanf("%d",&amp;matlab);
              opt-&gt;matlab = matlab;
              break;
          case 1:
              printf("Use this program to display plots (0 no, else yes): ");
              scanf("%d",&amp;usePl);
              opt-&gt;usePl = usePl;
              break;
          case 2:
              printf("Record Data for Graph of Theta (0 no, else yes): ");
              scanf("%d",&amp;thetaGraph);
              opt-&gt;thetaGraph = thetaGraph;
              break;
          case 3:
              printf("Record Data for Graph of Omega (0 no, else yes): ");
              scanf("%d",&amp;omegaGraph);
              opt-&gt;omegaGraph = omegaGraph;
              break;
          default:
              printf("Invalid Input!");
              break;
      }
      return 1;
  }
  </code></pre>
  
  <p>anyways, i believe i have declared both filename as 255 char, .. the compiler doesnt make mistakes.. so i figured it is me :)
  where did i go wrong? 
  The idea is i have a function that creates a sweep over a parameters, such as the driving force.. and i need the simulation to dump files of that data:
  - results1.txt
  - results2.txt
  - results3.txt</p>
  
  <p>which raises another question, but i surely find the answer to it, google... 
  how can i transform from int to char in c. Simple casting probably? </p>
  
  <p>thanks again</p>