Pages: [1]   Go Down
Author Topic: How to get a char from a char array  (Read 525 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 106
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

I have:   
Code:
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!
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
char carMes = clientline[10];
Logged

"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.

Offline Offline
Full Member
***
Karma: 0
Posts: 106
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you very mutch, at least it didn't give me error.
Thanks again!
 smiley-lol
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 106
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!) 
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 106
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Logged

"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.

Offline Offline
Full Member
***
Karma: 0
Posts: 106
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes i've corrected it meanwhile that i have forget the ' '  smiley-grin 
Thanks!
Logged

Pages: [1]   Go Up
Jump to: