Convert Char to int?

I am trying to convert a char to an integer variable.

#if defined(ARDUINO) && ARDUINO > 18
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetDHCP.h>

int gatestatus;
gatestatus = readvalues();
int readvalues()
    Serial.println("In Read Values");
    if (client.connect()) {
    Serial.println("Readvalues client connected");
    client.println("GET /headgateget.php");
    client.print( millis() );          // prevent caching, like justjed said a post before
    client.println("HTTP/1.0");                // no need for 1.1
    // client.println("Connection: close");
    while (client.connected()){
      if (client.available()) {
      Serial.println("client is avaliable printing page");
      char c =;
      Serial.println("parsed page, C=");
      s = (int)c;
      return s;
    if (!client.connected()) {

This is a small excerpt from my code.
I tried doing it this way but when it returns s it returns the value 48 everytime. C is only equal to a 1 or a 0, in the serial prints it confirms this. However converting it to an integer doesnt seem to work the way I would assume. I searched around and tried atoi() but it says that it is not a function.

The ascii code for the character 0 has the value 48. If you subtract '0' from your character, you will get the value of the digit represented.

'atoi' is most certainly a function.

c is a char variable that received ‘0’ or ‘1’, NOT 0 or 1.

0 = ‘0’ - ‘0’
1 = ‘1’ - ‘0’

oh sounds easy enough so i should write s = c - '0';

so i should write


thanks guys!