I'm building a small program that takes english as input and give the equivalent morse values. For which I declared a set of values that is to be used during the morse equivalent represenation. And I get few errors which I'm posting here.
// global variables
int i=0;
char pattern[6];
char english[50];
char *final_string[50];
char fin[40];
int index=0;
#define NUM_CODES (32)
#define NUM_WORDS (32)
#define NUM_ABB (33)
int abb_flag=0;
static const char *codes[NUM_CODES] = {".....","....-","...-.","...--","..-..","..-.-","..--.","..---",
".-...",".-..-",".-.-.",".-.--",".--..",".--.-",".---.",".----",
"-....","-...-","-..-.","-..--","-.-..","-.-.-","-.--.","-.---",
"--...","--..-","--.-.","--.--","---..","---.-","----.","-----"
};
static const char *words[NUM_CODES] = {".","A","B","C","D","E","F","G",
"H","I","J","K","L","M","N","O",
"P","Q","R","S","T","U","V","W",
"X","Y","Z","?","0","1","2","4" };
--------------------------------
----------------------
----------
---
----
-
-
-
-
-
-
-
----
void findletter() {
int k;
// go through all the codes
for(k=0;k<NUM_CODES;k++) {
// check if code[i] matches pattern exactly.
if(strlen(pattern) == strlen(codes[k]) && strcmp(pattern,codes[k])==0) {
// match!
if(*words[k]=='.'){
// fin[0]=*final_string[0];
// fin[1]=*final_string[1];
// fin[2]=*final_string[2];
chk_abb();
// Serial.println(final_string);
}
else {
Serial.print(' ');
Serial.println(words[k]);
*final_string[index]=*words[k]; // line 162
/*
error: invalid types 'char* [50][char*(const char*, int)]' for array subscript
sketch_sep21a.ino:163:18: error: invalid types 'char [40][char* (const char*, int)]' for array subscript
sketch_sep21a.ino:163:40: error: invalid types 'char* [50][char* (const char*, int)]' for array subscript
sketch_sep21a.ino:165:9: error: ISO C++ forbids incrementing a pointer of type 'char* (*)(const char*, int)' [-fpermissive]
sketch_sep21a.ino:165:9: error: lvalue required as increment operand
*/
fin[index]= *final_string[index] // line 163
++index; // line 165
i=0;
}
}
}
}
void chk_abb(){
int k;
// go through all the codes
for(k=0;k<NUM_ABB;k++) {
// check if code[i] matches pattern exactly.
if(strlen(fin) == strlen(abb[k]) && strcmp(fin,abb[k])==0) {
// match!
Serial.print(' ');
Serial.println(full_form[k]);
//tts the abb;
flag=1;
}
}
if(flag==0) {
//tts the sentence
}
index=0; // line 203
/*
error: assignment of function 'char* index(const char*, int)'
sketch_sep21a.ino:203:12: error: cannot convert 'int' to 'char* (const char*, int)' in assignment */
}
I tried to change the finalstring as a normal char data type rather then having a pointer one , still errors prevail. I've tried many but failed, If someone could pointed me out and explain whats the wrong I'm making here it would be gratefull.
Any suggestions are arppreciated. Thanks.
-SH
Aucun commentaire:
Enregistrer un commentaire