Unterminated string literal

V

vanitha

Hi All,

I am using "C" to generate the javascript code. And i am getting the
following error message "Unterminated string literal" in the mozilla
webbrowser for the following syntax.

unsigned char *Buf="Test"

printf("alert(\"%s\");\n\n",Buf);

I see an error message alert("Test Unterminated string literal in the
Javascript console of Mozilla web browser.
 
W

Walter Roberson

I am using "C" to generate the javascript code. And i am getting the
following error message "Unterminated string literal" in the mozilla
webbrowser for the following syntax.
unsigned char *Buf="Test"

I see an error message alert("Test Unterminated string literal in the
Javascript console of Mozilla web browser.

I take it this is intended to be the C code that runs within the
context of a CGI script that will send output to a browser?

You are missing the semicolon after the declaration line.

One variation you could experiment with is to use

printf("alert('%s');\n\n",Buf);

Either way, in the general case unless you know that
the contents of Buf is safe, you should pass it through a routine
to escape any quote-marks it has internally.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,427
Latest member
HildredDic

Latest Threads

Top