char function

i read alot and watched a lot of tutorials and im still confused on what the means. what goes in there?

example; char sms_rx[122]; //Received text SMS

char is a character or one byte. The is used to declare an array - the number in the square brackets defines the number of elements in the array.

ya but in the example there is no array

it gets used here;
gsm.IsSMSPresent(type_sms);

is not the same as( ). hold an array size or element index. ( ), in the line that you posted, would enclose parameters passed to a function.

sorry sorry i ment it gets used here

Serial.println(sms_rx);

see my problem is it dosnt display the texts i send to the gsm shield and i thought maybe this # is wrong or what is even means

Do you think it's time for you to post your whole program ?

#include <SoftwareSerial.h> 
#include <GSM_Shield.h>

//**************************************************************************
char number[]="#########";  //here would be my # but i wont show it 
char text[]="pump is working GREAT!!";  //SMS to send
byte type_sms=SMS_UNREAD;      //Type of SMS
byte del_sms=1;                //0: No deleting sms - 1: Deleting SMS
//**************************************************************************

GSM gsm;
char sms_rx[102]; //Received text SMS
//int inByte=0;    //Number of byte received on serial port
char number_incoming[20];
int call;
int error;


void setup() 
{
  Serial.begin(9600);
  Serial.println("system startup"); 
  gsm.TurnOn(9600);          //module power on
  gsm.InitParam(PARAM_SET_1);//configure the module  
  gsm.Echo(1);               //enable AT echo 

}


void loop()
{ 
  char inSerial[5];   
  int i=0;
  delay(2000);
  
    Check_Call(); //Check if there is an incoming call
    Check_SMS();  //Check if there is SMS 
    //Check data serial com 
    
    if (Serial.available() > 0) 
    {             
       while (Serial.available() > 0) {
         inSerial[i]=(Serial.read()); //read data  
         i++;      
       }
       inSerial[i]='\0';
      Check_Protocol(inSerial);
    }
       
}  

void Check_Protocol(String inStr)
{   
       Serial.print("Command: ");
       Serial.println(inStr);
       
  Serial.println("Check_Protocol");
  
    switch (inStr[0])
      {
       case 'a' :  //Answer        
           if (gsm.CallStatus()==CALL_INCOM_VOICE){
             gsm.PickUp();
             Serial.println("Answer");
           }
           else
           {
             Serial.println("No incoming call");
           }
         break;
       
    
       case 'c': // C  //Call
         if (inStr.length()<2)  //To call variable 'number'    comand   c
         {
           Serial.print("Calling ");
           Serial.println(number);         
           gsm.Call(number);
         }
         if (inStr.length()==2)  //To call number in phone book position   comand   cx where x is the SIM position
         {
             error=gsm.GetPhoneNumber(inStr[1],number);
             if (error!=0)
             {
               Serial.print("Calling ");
               Serial.println(number);
               gsm.Call(number);
             }
             else 
             {
               Serial.print("No number in pos ");
               Serial.println(inStr[1]);
             }
         }
         break;
          
       case 'h': //H //HangUp if there is an incoming call
         if (gsm.CallStatus()!=CALL_NONE)         
         {
           Serial.println("Hang");
           gsm.HangUp();              
         }
         else
         {
           Serial.println("No incoming call");
         }    
         break;
         
         
       case 's': //S //Send SMS
         Serial.print("Send SMS to ");
         Serial.println(number);
         error=gsm.SendSMS(number,text);  
         if (error==0)  //Check status
         {
             Serial.println("SMS ERROR \n");
         }
         else
         {
             Serial.println("SMS OK \n");             
         }
         break;
              
       case 'p':  //Read-Write Phone Book
         if (inStr.length()==3)
         {
           
           switch (inStr[1])
           {
             case 'd':  //Delete number in specified position  pd2
               error=gsm.DelPhoneNumber(inStr[2]);
               if (error!=0)
               {
                 Serial.print("Phone number position ");
                 Serial.print(inStr[2]);
                 Serial.println(" deleted");
               }
               break;
               
               
               
             case 'g':  //Read from Phone Book position      pg2
               error=gsm.GetPhoneNumber(inStr[2],number);
               if (error!=0)  //Find number in specified position
               {
                 Serial.print("Phone Book position ");
                 Serial.print(inStr[2]);
                 Serial.print(": ");
                 Serial.println(number);
               }
               else  //Not find number in specified position
               {
                 Serial.print("No Phone number in position ");
                 Serial.println(inStr[2]);
               }
               break;
             case 'w':  //Write from Phone Book Position    pw2
               error=gsm.WritePhoneNumber(inStr[2],number);
               if (error!=0)
               {
                 Serial.print("Number ");
                 Serial.print(number);
                 Serial.print(" writed in Phone Book position ");
                 Serial.println(inStr[2]);
               }
               else Serial.println("Writing error");
               break;
               
               
               
           }
           
         }
         break;
         
       }
   
    delay(1500);
    
    return;
 }
 
 
 void Check_Call()  //Check status call if this is available
 {     
     call=gsm.CallStatus();
     switch (call)
     {    
       case CALL_NONE:
         Serial.println("no call");
         break;
       case CALL_INCOM_VOICE:
         gsm.CallStatusWithAuth(number_incoming,0,0);        
         Serial.print("incoming voice call from ");     
         Serial.println(number_incoming);
         break;
       case CALL_ACTIVE_VOICE:
         Serial.println("active voice call");    
         break;
       case CALL_NO_RESPONSE:
         Serial.println("no response");
         break;
     }
     return;
 }
 
 
 void Check_SMS()  //Check if there is an sms 'type_sms'
 {
     char pos_sms_rx;  //Received SMS position     
     pos_sms_rx=gsm.IsSMSPresent(type_sms);
     if (pos_sms_rx!=0)
     {
       //Read text/number/position of sms
       gsm.GetSMS(pos_sms_rx,number_incoming,sms_rx,120);
       Serial.print("Received SMS from ");
       Serial.print(number_incoming);
       Serial.print("(sim position: ");
       Serial.print(word(pos_sms_rx));
       Serial.println(")");
       Serial.println(sms_rx);
       if (del_sms==1)  //If 'del_sms' is 1, i delete sms 
       {
         error=gsm.DeleteSMS(pos_sms_rx);
         if (error==0)Serial.println("SMS deleted");      
         else Serial.println("SMS not deleted");
       }
     }
     return;
 }

hooverdan:
i read alot and watched a lot of tutorials and im still confused on what the means. what goes in there?

example; char sms_rx[122]; //Received text SMS

OK, let me see if I can EXPLAIN it to you (since nobody else has so far).

The brackets make the variable an array... a "string" of memory where data can be written to or read from. By "string" I don't mean "text string" or "string library", but just a "bunch" of storage places.

Let's say you do this:

[b]char msg[32];[/b]

this defines a row of 8 bit signed characters with a count of 32. You can also say that it RESERVES a 32 byte space in ram that you can do with whatever you want (but never exceed the reserved size or you will run into other variables and crash the Arduino!

In ram, it looks like this (addresses may vary and are decided by the compiler and are not our concern):

[b]Address   Data
-------   ----
0x0100    0x00
0x0101    0x00
0x0102    0x00
......
0x011D    0x00
0x011E    0x00
0x011F    0x00
[/b]

Initially, since the array isn't used yet, it's just filled with zero. Now, let's put some data into it:

[b]msg[0] = 'H';
msg[1] = 'e';
msg[2] = 'l';
msg[3] = 'l';
msg[4] = 'o';
[/b]

The first location of the array is filled with hex 0x48 which is the letter "H". The second array element has 0x65 placed into it (the letter "e"), etc.... get it?

Now let's look at raw memory again:

[b]Address   Data
-------   ----
0x0100    0x48
0x0101    0x65
0x0102    0x6C
0x0103    0x6C
0x0104    0x6F
0x0105    0x00
......
0x011D    0x00
0x011E    0x00
0x011F    0x00[/b]

Now, if you do this:

[b]Serial.print (msg[0]);
[/b]

which, said in words is "print the contents of the first element in the array called "msg" You get the letter "H" printed.

Now if you do this:

[b]Serial.print (msg);[/b]

it will print each character in the array, one after another, until it runs into the null (zero) (located at address 0x0105), so of course the result will be that it prints "Hello".

Now, let's say you made a 100 location array and stored a temperature reading into one element after another at one minute intervals. You could then read array[0] to get the first one, array[59] to get the data from one hour later (note I said 59 because the count is zero based... 0....59 is a count of 60), etc...

Make sense?

Do these help your understanding?

ya thank you both i understand it now but now that i know i still didn't fix my overall problem i posted a new topic