Hello! I am stuck with this problem:
define array size=10. I want to output what I entered (char), and the array size. For example:
(1)input: abcdefgh
Serial monitor: array size= 8, your input: abcdefgh
(2)input: abcdef ghijklm
Serial monior: array size= 10, your input: abcdef ghi
Can I have a program for reference? thank you!!

This tutorial may help you:
Serial Input Basics
Here is the serial input basics tutorial example #2 slightly modified to do what you want. Read the tutorial to see how the serial reception works. The modification is to make the ndx variable (counts characters entered) global in scope so that it is visible to the rest of the program. Make sure that line endings in serial monitor is set to Newline or both Lf & CR.
// Example 2 - Receive with an end-marker
const byte numChars = 32;
char receivedChars[numChars]; Â // an array to store the received data
boolean newData = false;
byte ndx = 0;
void setup()
{
 Serial.begin(9600);
 Serial.println("<Arduino is ready>");
}
void loop()
{
 recvWithEndMarker();
 showNewData();
}
void recvWithEndMarker()
{ Â
 char endMarker = '\n';
 char rc;
 while (Serial.available() > 0 && newData == false)
 {
   rc = Serial.read();
   if (rc != endMarker)
   {
    receivedChars[ndx] = rc;
    ndx++;
    if (ndx >= numChars)
    {
      ndx = numChars - 1;
    }
   }
   else
   {
    receivedChars[ndx] = '\0'; // terminate the string
    ndx = ndx;
    newData = true;
   }
 }
}
void showNewData()
{
 if (newData == true)
 {
   Serial.print("Array size = ");
  Serial.print(ndx);
  Serial.print("  your input: ");
   Serial.println(receivedChars);
   ndx = 0;
   newData = false;
 }
}
Output:
<Arduino is ready>
Array size = 4 Â your input: 123
Array size = 9 Â your input: 12345678
Wait a minute, you say. There are only 3 and 8 characters in those arrays. Nope, those are strings so there is an invisible null to terminate the array. If you only care about the visible characters, subtract 1 from ndx.
kelvinmatt:
Can I have a program for reference?
That you can submit with your name on it?