Hi all:
Got a formatting question here:
Trying to send data string over to a server via send();
The problem is that I want to enclose the data string with double-quotes, "data string" should be displayed on the server side. The method I used is using two double_quotes on each end of the data string, writing the string with the double_quotes to another string and lastly, send the second string using send(). However, the result is the data string without the double quotes I added? Why?


_snprintf(user_message,MESSAGE_LINE_SIZE, "MESSAGE ""%s""\r",s);


Recommended Answers

All 4 Replies

C is not VB.

_snprintf(user_message,MESSAGE_LINE_SIZE, "MESSAGE \"%s\"\r",s);

>>"MESSAGE ""%s""\r"
The reason this doesn't work the way you want it is because that is a standard way of concantinating string literals and the compiler will just make one string out of it.

char str[] = "Hello " "World"
is the same as this
char str[] = "Hello World"

Thanks man. It worked.

Hi dragon, good to see you again.
Thanks for you info, I always learn something new from you.
Thank you again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.