Go Down

Topic: How to get a char from a char array (Read 624 times) previous topic - next topic

blastboot

Hello, i'm trying to get a char from an known position of a char array.

I have:   
Code: [Select]
char clientline[128] //A char array to save data sent from the client (over the internet)

(strstr(clientline, "GET /&logg") != 0) { //using this to know the command needed

//When i get -> "GET /&logg1" or "GET /&logg2" or "GET /&logg3" .... or "GET /&logg9" or "GET /&logg#" or "GET /&logg%" or "GET /&logg&"  --> each one will correspond to a month (so they are 12, because of 12 months)

char carMes = clientline.charAt(10); //By reading arduino.cc/reference i thought that this should be the function that i need
switch (carMes) {
            case 1: ficheiroLer = "Jan.csv";
            break;
            case 2: ficheiroLer = "Fev.csv";
            break;
            case 3: ficheiroLer = "Mar.csv";
            break;
            case 4: ficheiroLer = "Abr.csv";
            break;
            case 5: ficheiroLer = "Mai.csv";
            break;
.... until it performs 12 (for 12 months) to provide the download of a logg file.


I'm getting this error code " error: request for member 'charAt' in 'clientline', which is of non-class type 'char [128]' "

Need your help to understand what i'm doing wrong.
Thanks in advance!

AWOL

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

blastboot

Thank you very mutch, at least it didn't give me error.
Thanks again!
XD

blastboot

I need help one more time. It is 12 months so the switch case fuction works well from 0 to 9 which means that it works for me to identify 10 months, but it is 2 left. I try to use # or & but the function doesn't accept it.
So what can i do to make it working?

Thanks in advance (again!) 

blastboot

Ok i've put letters to solve the problem. Maybe next time i'll take more time thinking the problem before posting... :smiley-red:

Thanks again!

AWOL

I could understand it if the value at location 10 were an ASCII digit, thus
Code: [Select]
switch (carMes) {
           case '1': ficheiroLer = "Jan.csv";


but not as you have it
Code: [Select]
switch (carMes) {
           case 1: ficheiroLer = "Jan.csv";


"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

blastboot

Yes i've corrected it meanwhile that i have forget the ' '  :D 
Thanks!

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy