user53821: I have made a class called subjects and I have then made a subject called math. I am trying to set a classroom for math but it is giving me the error 'math' doesn't name a type.
Code for the class
class subject {
public:
  char subjectname[];
  char classroom[];

};

Code for the classroom and math
subject math;
math.classroom = "A1";

How can I set the classroom of math to A1?

user30175: class subject {
public:
  char subjectname[];
  char classroom[];

};

This creates a class subject which has two char arrays of unspecified size as its members. This will attempt to create an array of size 0 (see here). This is not what you want. You can e.g. statically allocate the space with a maximum number of characters beforehand and then strncpy() your new string inside the buffer.
This would look like 
class subject {
public:
  char subjectname[32];  //32 bytes buffer
  char classroom[32];
};

And later 
subject math;
strncpy(math.classroom, "A1", 31); //copy at max 31 bytes to not overwrite the NUL terminator
Serial.print("Classroom is: ");
Serial.println(math.classroom)

Or, just use the Arduino String class.  For example  
#include <Arduino.h>
class subject {
public:
  String subjectname;
  String classroom;
};

Then your first usage code can be used unmodified.
Example
#include <Arduino.h>

class subject {
public:
  String subjectname;
  String classroom;
};

void setup() {
    Serial.begin(115200);

    subject math;
    math.classroom = "A1";

    Serial.print("Classroom is: ");
    Serial.println(math.classroom);
}

void loop() { }


53821: <p>I have made a class called subjects and I have then made a subject called math. I am trying to set a classroom for math but it is giving me the error 'math' doesn't name a type.</p>

<p>Code for the class</p>

<pre><code>class subject {
public:
  char subjectname[];
  char classroom[];

};
</code></pre>

<p>Code for the classroom and math</p>

<pre><code>subject math;
math.classroom = "A1";
</code></pre>

<p>How can I set the classroom of math to A1?</p>
 30175: <pre><code>class subject {
public:
  char subjectname[];
  char classroom[];

};
</code></pre>

<p>This creates a class <code>subject</code> which has two <code>char</code> arrays of unspecified size as its members. This will attempt to create an array of size 0 (see <a href="https://stackoverflow.com/questions/9722632/what-happens-if-i-define-a-0-size-array-in-c-c">here</a>). This is not what you want. You can e.g. statically allocate the space with a maximum number of characters beforehand and then <code>strncpy()</code> your new string inside the buffer.</p>

<p>This would look like </p>

<pre><code>class subject {
public:
  char subjectname[32];  //32 bytes buffer
  char classroom[32];
};
</code></pre>

<p>And later </p>

<pre><code>subject math;
strncpy(math.classroom, "A1", 31); //copy at max 31 bytes to not overwrite the NUL terminator
Serial.print("Classroom is: ");
Serial.println(math.classroom)
</code></pre>

<p>Or, just use the Arduino <code>String</code> class.  For example  </p>

<pre><code>#include &lt;Arduino.h&gt;
class subject {
public:
  String subjectname;
  String classroom;
};
</code></pre>

<p>Then your first usage code can be used unmodified.</p>

<p>Example</p>

<pre><code>#include &lt;Arduino.h&gt;

class subject {
public:
  String subjectname;
  String classroom;
};

void setup() {
    Serial.begin(115200);

    subject math;
    math.classroom = "A1";

    Serial.print("Classroom is: ");
    Serial.println(math.classroom);
}

void loop() { }
</code></pre>
