Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Gelöst: conversion from void to non-scalar type String requested bei String.replace und toLowerCase

06.05.2020 (👁5631)


 

Fehlermeldung:

error: conversion from 'void' to non-scalar type 'String' requested

 

Fehlerzeile, Arduino Original-Code

Original von der Webseite Arduino.cc -> Tutorial/StringSubstring

String stringTwo = stringOne.replace("<html><head></head><body></body></html>", "Blah");

 

Debug Meldung

exit status 1

conversion from 'void' to non-scalar type 'String' requested

 

 

Lösung:

Keine Übergabe in eine zweite Variable

   stringTwo.replace("a","b");

 

 

 

 

Lösung:

Bei Replace(..) wird der Rückgabe nicht in eine zweite Variable übergeben, sondern das Ergebnis wird in die Variable selbst zurückgeschrieben

  // put your main code here, to run repeatedly:

   String stringOne = "abc";

   String stringTwo = stringOne;

   

   //ok: 

   stringTwo = stringTwo.substring(2);

   //ok:

   stringTwo.replace("a","b");

   

   //error:

   //string as result of string.replace(a,b)

   stringTwo = stringOne.replace("a","b");