strcpy question

Hi -
I have a small problem using strcpy.
Here is my code:

#include <SPI.h>
#include <WiFi.h>

char ssid[] = "network";      //  your network SSID (name) 
char pass[] = "pass";   // your network password

int status = WL_IDLE_STATUS;

// Initialize the Wifi client library
WiFiClient client;

// server address:
char server[] = "130.226.142.6";
//IPAddress server(130,226,142,6);

String location = "/people/magk/index.php HTTP/1.0";
String pageValue;
char inString[32]; // string for incoming serial data
char cpString;
int stringPos = 0; // string index counter
boolean startRead = false; // is reading?

unsigned long lastConnectionTime = 0;           // last time you connected to the server, in milliseconds
boolean lastConnected = false;                  // state of the connection last time through the main loop
const unsigned long postingInterval = 10*1000;  // delay between updates, in milliseconds

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600); 
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  
  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present"); 
    // don't continue:
    while(true);
  } 
  
  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) { 
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:    
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  } 
  // you're connected now, so print out the status:
  printWifiStatus();
  pageValue = connectAndRead(); //connect to the server and read the output
  Serial.println(pageValue); //print out the findings
}

void loop() {
 

  //delay(5000); //wait 5 seconds before connecting again
  // if you're not connected, and ten seconds have passed since
  // your last connection, then connect again and send data:
  if(!client.connected() && (millis() - lastConnectionTime > postingInterval)) {
    pageValue = connectAndRead();
    Serial.println(pageValue); //print out the findings  
  }
  // store the state of the connection for next time through
  // the loop:
  lastConnected = client.connected();

}

String connectAndRead(){
  //connect to the server

  Serial.println("connecting...");

  //port 80 is typical of a www page
  if (client.connect(server, 80)) {
    Serial.println("connected");
    client.print("GET ");
    client.println(location);
    client.println();

    //Connected - Read the page
    return readIP(); //go and read the output
    // note the time that the connection was made:
    lastConnectionTime = millis();
  } 
  else {
    // if you couldn't make a connection:
    Serial.println("connection failed");
    Serial.println("disconnecting.");
    client.stop();
  }
}


void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

String readIP(){
  //read the page, and capture & return everything between '<' and '>'
  char charval[32];
  stringPos = 0;
  memset( &inString, 0, 10 ); //clear inString memory

  while(true)
  {
    if (client.available()) 
    {
      char c = client.read();
      if (c == '<' ) 
      { //'<' is our begining character
        startRead = true; //Ready to start reading the part 
      }
      else if(startRead)
      {
        if(c != '>')
        { //'>' is our ending character
          inString[stringPos] = c;
          stringPos ++;
        }
        else
        {  //got what we need here! We can disconnect now
          startRead = false;
          client.stop();
          client.flush();
          Serial.println("disconnecting.");
        //  strcpy(cpString, inString); //<-- this doesn't work.
          return inString;
        }
      }
    }
  }
}

What I’m trying to achieve:
is to copy the IP address stored in inString. The Arduino WiFi shield will then connect to the new IP address as the IP of the device (phone) that the WiFi Shield connects to changes.

It may be that there is a straightforward solution and that I’ve just stared myself blind…
I look forward to your helpful comments and suggestions.

Thanks.
Moxi

char inString[32]; // string for incoming serial data
char cpString;
...
        //  strcpy(cpString, inString); //<-- this doesn't work.

strcpy() expects two strings. You’re passing it a string and a char.

Ah yes - that would explain it. Thank you for your reply!

strcpy(cpString, inString); //<-- this doesn't work

sp. “This doesn’t compile”

If it doesn’t compile, it doesn’t download.
If it doesn’t download, it doesn’t run.
If it doesn’t run, then it can’t be said to work/not work, so saying that something that doesn’t even compile doesn’t work is a tad premature.

my oh my - a bit touchy aren't we ;) Thank you for your helpful comment.

It is true that, that part of the code doesn't compile, the rest, however, does.

Kindly, Moxi

my oh my - a bit touchy aren't we

No. Code has to compile, link, and upload before the correctness of the logic can be determined. If you can't get to step 4 (1) compiled, 2) linked, 3) uploaded, and 4) observed to run) then you are wasting our time helping you find the logic error(s).

Say, up front, exactly what the problem is, and we'll be less picky about it when it turns out you are wasting our time.

my oh my - a bit touchy aren't we

No.

If you say "it doesn't work", there's an expectation that the code compiles but doesn't perform as hoped.

But you said "I have a small problem using strcpy."

Again, you weren't "using" strcpy, because the code would not compile, but you didn't even bother to post the simple error message that would have made the problem immediately obvious, rather, we had to trawl through 150 lines of your code.