String type in arduino ide is not wroking!

Hi,
I have done many projects in hifive1 but today i am facing an issue, i just uploaded a program from examples. It is not printing the String variables in serial monitor. But the same code works in arduino uno.
Can someone tell me the reason? and what should i do to solve the problem?

    void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Serial.println("\n\nString charAt() and setCharAt():");
}

void loop() {
  // make a String to report a sensor reading:
  String reportString = "SensorReading: 456";
  Serial.println(reportString);

  // the reading's most significant digit is at position 15 in the reportString:
  char mostSignificantDigit = reportString.charAt(15);

  String message = "Most significant digit of the sensor reading is: ";
  Serial.println(message + mostSignificantDigit);

  // add blank space:
  Serial.println();

  // you can also set the character of a String. Change the : to a = character
  reportString.setCharAt(13, '=');
  Serial.println(reportString);

  // do nothing while true:
  while (true);
}

Hifive1 output:

String charAt() and setCharAt():

A “while (true);” in your loop() function is at the very least unconventional!

What happens if you remove it? I would hope you’ll get the same output messages repeated continuously.

If you do, then that loop is probably preventing an output buffer from being flushed.

Or, you might try inserting “Serial.flush();” before it.

I took this code from
File->Examples->Strings(from Built-in-examples)->StringCharacters.

I compiled and flashed the same code from another system which has arduino ide. It worked! i am getting the desired output!

But when i flashed the code again from the system that i am using regularly it stops at the first Serial.println() itself.

Couldn’t predict the issue of what! should i reinstall the Arduino ide?
I am suspecting the “String” type .

You are flashing the same HiFive1 board from two different PCs with different results?

Yes bruce

Then it seems you have different versions of the IDE on the two machines, or at least different (or maybe corrupted) versions of the libraries.

Have you tried the code changes I suggested?

I dint try it out as my office time got over.I will do it on Monday.

This issue has started with my other project (hifive1 communicating with esp-01 ).
When I initialized String variables for SSID and Password and some more, I faced some errors like this
“_dso_handle undefined reference”

When I commented those initialisation the code gets compiled successful.

So, to find out the problem I tried with an example program which contains String variables .

And I am damn sure that this String data types worked perfectly during my previous projects.

Didn’t Hifive1 revb board dropped support for Arduino IDE?

Yes. I assume Daniel is talking about the original board because the Arduino IDE doesn’t even have a way to flash the RevB. In fact I think that’s probably the main issue. I’m sure the RevB could be made to work if someone has time to work on it.

I am not using RevB version.

I tried according to your suggestion bruce, still getting the same issue.
And also i just added this snippet,

  Serial.println("\n\nString charAt() and setCharAt():");
  char *hello="hello";
  Serial.println(hello);
  String reportString = "SensorReading: 456";
  Serial.println(reportString);

and the output is

String charAt() and setCharAt():
hello

These are the tests that i have done in the morning in different systems.

I)Windows10(currently i am using)
Arduino version 1.8.9
output:

String charAt() and setCharAt():

II)Linux(ubuntu 18.04)
Arduino Version 1.8.8
output:

        String charAt() and setCharAt():
        SensorReading: 456
        Most significant digit of the sensor reading is: 4
        SensorReading= 456

III)Windows7 (colleague’s system)
Arduino Version 1.8.8
output:

String charAt() and setCharAt():

I guess, if i reinstall the ide in my system again , the same issue will occur.,