79091007

Date: 2024-10-15 17:05:36
Score: 1.5
Natty:
Report link

I found that my problem was with the strings having some extra hidden information that needed to be removed before trying to convert the string to a char * array. After reading the str I added a str.trim() function that cleaned up the string. I was then able to use str.c_str() and get a url address. Without using str.trim() the string printed okay but did not work as a url address.

'''

virtual int size(){
      //read and count the number of stations and store values in String array
        File url_list = SD.open(listurls);
        String str;
        int count = 0;
        while (url_list.available() && count < MAX_LINES) {
          str= url_list.readStringUntil('\n');
          str.trim();
          url_addr[count]=str;
          count++;
        }
        max=count;
        url_list.close();
        return max;

    ...

    char * a_url = url_addr[count].c_str;

'''

Reasons:
  • Blacklisted phrase (1): did not work
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: waszee