String & Functions

I am ashamed , but I do not understand why this code is bad…

String test();

void setup()
{
    Serial.begin(9600);
    while(!Serial.available()) SPARK_WLAN_Loop();
    String ts2 = test();
    Serial.print( ts2 );
}

void loop() {

}

String test()
{
    String cc = "test";
    return test;
}

Some help for me ? :smiley:
Thanks


I’ve edited your post to properly format the code. Please check out this post, so you know how to do this yourself in the future. Thanks in advance! ~Jordy

try:

String test()
{
    String cc = "test";
    return cc;
}
3 Likes

I agree with @BulldogLowell, but I also guess, if you had read the error message you got propperly you might have found this out yourself.

2 Likes

@blondie63 , if you compile the code that you gave us in the web ide though, you’ll get an error (a long with other less relevant info) that looks like

ga.cpp:18:12: error: could not convert 'test' from 'String (*)()' to 'String'

The key thing to get from that is the line number, 18, which is always a good place to start your search for problems…

2 Likes

Sorry, i written too late yesterday… i was very tired :blush: