Si prega di prendere il seguente:Definire una stringa su più righe
char buffer[512];
memset(buffer, 0, sizeof(buffer));
sprintf(&buffer[0],"This Is The Longest String In the World that in text goes on and..");
printf("Buffer:%s\r\n",buffer);
Vorrei essere in grado di creare questa stringa su più righe, per la facilità di risoluzione dei problemi e la modifica. Tuttavia, quando utilizzo il comando \
, il mio output è separato da ciò che sembra essere tabs?
Esempio:
sprintf(&buffer[0],"This Is The\
Longest String In the World\
that in text goes on and..");
produce una potenza di:
Buffer:This Is The Longest String In the World that in text goes on and..
Tutte le idee? È solo un approccio scorretto per provare a suddividere una stringa su più righe di codice?
Non dovrebbe usare '\ R' in' printf' –
Perché sulla terra non? – Mawg
Possibile duplicato di [Come dividere una stringa letterale su più righe in C/Objective-C?] (Http://stackoverflow.com/questions/797318/how-to-split-a-string-literal-across-multiple -lines-in-c-obiettivo-c) –