This C++ program. I am texting this code. However, my softward shows me These er
ID: 3671563 • Letter: T
Question
This C++ program. I am texting this code. However, my softward shows me These error messages.
text.cpp: In function ‘int main()’:
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
text.cpp:14: warning: deprecated conversion from string constant to ‘char*’
I have tried to fixed this error, but I don't know where is wrong, I have tried many ways. If my softword can't read these code?
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int operatingMode = 0;
char latinPhrase;
char morseBuffer[500];
char latinAlphabet[29] = { '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', '.', ',',' '};
char *morseAlphabet[29] = { ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", ".-.-.-", "--..--", " " };
operatingMode=-1;
do{
cout << "Do you want to translate text to Morse code (1) or translate Morse code to text (2)?" << endl;
cin >> operatingMode;
}while((operatingMode != 1) && (operatingMode != 2));
cout << "Your mode of operation is " << operatingMode << endl;
if (operatingMode == 1)
{
bool FirstChar = true;
cout << "Enter Text Message: ";
cin.ignore();
while(cin.get(latinPhrase)){
bool Found=false;
int i = 0;
int j = 0;
if(FirstChar == true){
cout<<"Morse Code: ";
FirstChar = false;
}
latinPhrase = toupper(latinPhrase);
if(latinPhrase == ' '){
cout<<" ";
Found = true;
}
if(latinPhrase == ' '){
cout<<endl;
return 0;
Found = true;
}
while((Found == false) && (i < 29)){
if(latinPhrase == latinAlphabet[i]){
Found = true;
while(morseAlphabet[i][j] != 0){
cout<<morseAlphabet[i][j];
j++;
}
cout<<" ";
}
i++;
}
if(Found == false){
cout<<"You have entered an invalid character. Please try again later."<<endl;
return 0;
}
}
cout<<"End of output";
cout<<endl;
return 0;
}
if (operatingMode == 2)
{
bool FirstChar = true;
bool Found=false;
bool endofcharacter = false;
bool endofline = false;
int len;
int i;
int k = 0;
int l = 0;
cout << "Enter Morse Code: ";
cin.ignore();
while((cin.get(morseBuffer[k]))){
if(morseBuffer[k] == ' '){
morseBuffer[k] = ' ' ;
}
else if(morseBuffer[k] == ' ')
break;
else{
}
k++;
}
morseBuffer[k]=0;
len = k;
k=0;
while(morseBuffer[k] != 0){
/* scoot up to the first character */
while(morseBuffer[k] == ' '){
cout<<" ";
k++;
}
for(i = 0; i < 29; i++){
Found = true;
for(l = k; (morseBuffer[l] != ' ') &&(morseBuffer[l] != 0) ; l++)
if((morseBuffer[l] != morseAlphabet[i][l-k])){
Found = false;
}
if(((morseBuffer[l]==' ') && !(morseAlphabet[i][l-k] == 0))||
((morseBuffer[l]==0) && !(morseAlphabet[i][l-k] == 0)))
Found = false;
if(!Found)
continue;
else{
cout<<latinAlphabet[i];
k = l;
break;
}
}
}
cout<<endl;
return 0;
}
}
Explanation / Answer
there is no error in the code it is perfect and running . you please try uninstalling the software and try installing again
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.