A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
For an assignment, I'm unable to use the strings.
Only c-style strings.
From where did the C++ code you posted come? It seems
unlikely that you wrote all of it.
a5.cpp:59:27: error: excess elements in char array initializer
char morse_code[36]={".-","-...","-.-.","-..",".","..-.","--.",
"....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",
".-.","...","-","..-","...-",".--","-..-","-.-...
You have declared an array of chars, but the initializers
you specified are string literals. One alternative:
const char *morse_code[36] = { ".-","-...","-.-.","-..",
".","..-.","--.","....","..",".---","-.-",".-..","--",
"-.","---",".--.","--.-",".-.","...","-","..-","...-",
".--","-..-","-.--","--..","-----",".----","..---",
"...--","....-",".....","-....","--...","---..","----." };
a5.cpp:82:10: error: invalid operands to binary expression
('char [255]' and 'int')output += ' ';
The variable "output" is defined as an array of chars. So you
can't use the += operator as that only works with std::string.
You need to review how to build C-style strings (nul-terminated).
With suitable care when defining/declaring the char array which
is to hold the string being built - including presetting it to
binary zeros and ensuring that it is large enough - you can
make use of C runtime library functions such as:
strcpy
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/strcpy-wcscpy-mbscpy?view=msvc-170
memcpy
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/memcpy-wmemcpy?view=msvc-170
- Wayne