I want to have a array with multiple lines, but as my code sample shows, the C code doesn't recognize the ", also depending on the IDE the code is having a diferrent behavior, I tried change the inside " for ' but it doesn't work too
char palavra2 [] = "{Conversor de Temperatura: °C -> °F}
prg Exemplo_02;
{Declaração de variáveis}
var
int c;
float f;
{Programa principal}
begin
write("Informe a temperatura em °C: ");
read(c);
f <- 1.8 * C - 32;
write("O correspondente em Fahrenheit é: ", f);
end."
CodePudding user response:
Your string cannot span multiple line like this. The two good options are:
char palavra2[] = "{Conversor de Temperatura: °C -> °F}\n\
prg Exemplo_02;\n\
...";
or:
char palavra2 [] =
"{Conversor de Temperatura: °C -> °F}\n"
"prg Exemplo_02;\n"
"...";
You can, of course, store your string in a file and open/read it into a string.
The next c standard (c23) includes an #embed
feature to include arbitrary data from an external file.